I have a form that has an option for uploading file
<form type="upload" name="myForm" target="rgUsrStory">
<field name="st_title" title="${uiLabelMap.uStoryTitle}"><text/></field>
<field name="upload_file" title="${uiLabelMap.UploadFile}"><file/></field>
<field name="submitButton" title="${uiLabelMap.submit}"><submit/></field>
</form>
request map:
<request-map uri="rgUsrStory">
<security https="true" auth="true"/>
<event type="java" path="org.ofbiz.webapp.control.usrStory" invoke="rgUsrStory" />
<response name="success" type="view" value="main"/>
<response name="error" type="view" value="login"/>
</request-map>
The event function is working properly, but i need to upload the file also to the server and details of that file to the table named as 'documents', but i don't know how to do that, i searched throw the web but only i found using ftl, also want to control the file type of defined file that i want to display those file types as allowed file in form during adding user story.
For any guide and help thanks.
Please have a look at the image upload functionality in the OFBiz content manager.
There's a form
<form name="ImageUpload" target="uploadImage" title="" type="upload" default-map-name="currentValue"
header-row-style="header-row" default-table-style="basic-table">
<field name="dataResourceId" title="${uiLabelMap.ContentDataResourceId}"><display/></field>
<field name="dataResourceTypeId" ><hidden/></field>
<field name="objectInfo" title="${uiLabelMap.ContentUploadedFile}"><display /></field>
<field name="imageData" entity-name="ImageDataResource" title="${uiLabelMap.ContentFile}"><file/></field>
<field name="submitButton" title="${uiLabelMap.CommonUpload}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
The corresponding request in the controller.xml
<request-map uri="uploadImage">
<security auth="true" https="true"/>
<event invoke="persistContentAndAssoc" path="" type="service"/>
<response name="success" type="request" value="UploadImage"/>
<response name="error" type="view" value="UploadImage"/>
</request-map>
The service name in services.xml lead you to the service method
<service name="persistContentAndAssoc" engine="java" transaction-timeout="7200"
location="org.ofbiz.content.ContentManagementServices" invoke="persistContentAndAssoc" auth="true">
<description>Create a Content, DataResource and/or ContentAssoc</description>
<permission-service service-name="genericContentPermission" main-action="CREATE"/>
...
</service>
In org.ofbiz.content.ContentManagementServices#persistContentAndAssoc the uploaded file is read by
ByteBuffer imageDataBytes = (ByteBuffer) context.get("imageData");
(the corresponding form field).
You will find some other functionality like dealing with the mime type there.
Related
Is there any way to dump all contents of xml file in a single content field??
schema.xml
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="content" type="text_general" indexed="true" stored="true" multiValued="false" termVectors="true" termPositions="true" termOffsets="true"/>
code used for indexing
HttpUrlConnection solrHttpURLConnection = "http://localhost:7892/solr/myCore/update/extract?literal.id=1234&commit=true "
solrHttpURLConnection.setDoOutput(true);
solrHttpURLConnection.setDoInput(true);
solrHttpURLConnection.setUseCaches(false);
solrHttpURLConnection.setAllowUserInteraction(false);
solrHttpURLConnection.setRequestProperty("Content-type", type);
solrHttpURLConnection.connect();
i am taking outputstream from this url and writing contents by taking input stream from dataServer.
NOTE:
the above code works for all file formats except xml,csv and json.
no error message is coming from solr
Sample XML File
<?xml version="1.0" encoding="UTF-8"?>
<content>just a test
</content>
Set the content type to "text/xml"
Add the following lines to your code:
OutputStreamWriter writer = new OutputStreamWriter(solrHttpURLConnection.getOutputStream());
writer.write(your_xml_file);
writer.flush();
Execute the request with this url http://localhost:7892/solr/myCore/update?literal.id=1234&commit=true
For json files use /update/json/docs
Please also check this documentation about uploading data with index handlers https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers#UploadingDatawithIndexHandlers-XMLUpdateCommands
I have several different XML files. I want to display them in HTML format using JSP file.
The structure of these files can be different. They may have different depth and tag's names.
I've read about XSLT but I found only examples with manually created xsl. (I can't do that because i will have many different xml files).
How can i produce my html?
EDIT:
Example of form:
<form name="Company">
<field name="name" required="true" type="inputText"/>
<field name="registrationDate" required="true" type="date"/>
<field name="isActive" required="false" type="boolean"/>
<field name="unregistrationDate" type="date"/>
<field name="type" type="comboBox">
<values>
<value>type1</value>
<value>type3</value>
<value>type3</value>
</values>
<defaultSelected>type2</defaultSelected>
</field>
</form>
I need to integrate into my Openerp application a third party developed java applet to sign documents electronicaly. I tried to implement the following solution but it didn't work for me:
https://stackoverflow.com/questions/24204467/applet-java-integration-with-openerp-odoo
I have the following java applet embeded into my xml view:
<openerp>
<data>
<record id="view_firma_form" model="ir.ui.view">
<field name="name">firma.form</field>
<field name="model">x_firma</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<form string="Firma" version="7.0">
<sheet>
<![CDATA[
<html>
<body>
<object id="signApplet" width="600" height="400" archive="ini4j-0.5.2-1.0.jar, icepdf-core-4.3.2-1.0.jar, icepdf-viewer-4.3.2-1.0.jar, AgesicFirmaApplet-AgesicFirmaApplet-2.5.jar, bcprov-jdk15-1.46-1.0.jar, commons-codec-1.2-1.0.jar, bcmail-jdk15-1.46-1.0.jar,log4j-1.2.14-1.0.jar,swing-layout-1.0.3-1.0.jar,commons-io-2.1-1.0.jar,bcprov-jdk15-1.46-1.0.jar,MITyCLibAPI-1.0.4-1.0.jar,MITyCLibCert-1.0.4-1.0.jar,MITyCLibXADES-1.0.4-1.0.jar,MITyCLibTSA-1.0.4-1.0.jar,jss-4.2.5-1.2.jar,commons-logging-1.1-1.0.jar, UserAgentUtils-1.2.4-1.0.jar,itextpdf-5.2.0-1.0.jar,bctsp-jdk15-1.46-1.0.jar,xmlsec-1.4.2-ADSI-1.0-1.0.jar">
<param name="type" value="application/x-java-applet;jpi-version=1.5.0"/>
<param name="java_arguments" value="-Xmx128m"/>
<param name="classloader_cache" value="false"/>
<param name="codebase" value="http://server/appletFirmaAgesic">
<param name="code" value="uy.gub.agesic.firma.cliente.applet.SignApplet"/>
</object>
</body>
</html>
]]>
</sheet>
</form>
</field>
</record>
When I try to execute that (it was installed with no problems), it throws the following error:
Uncaught Error: Invalid XML: <form string="Firma" version="7.0"><sheet>
Is there any way to do that or do I have to take another type of implementation.
Thanks
Page contains form which looks like below.
1) If I insert to form validate="true", then after page load this form submit request to mail action (at this point validation xml was not created yet).
2) After validation xml was created (in the same pakage with action), then action which control request to this page returns 404 page.
Did I miss something?
<s:form action="mail" method="post">
<s:textfield name="name" key="Your name" size="20" />
<div style="clear: both;margin-top:10px"></div>
<s:textarea label="Comment" name="comment" cols="65" rows="5"/>
<s:submit method="mail" key="Send" align="left"
style="width:100px; height:35px; margin-top:20px"/>
</s:form>
validation xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators>
<field name="name">
<field-validator type="required">
<message>Please enter a user name</message>
</field-validator>
</field>
<field name="comment">
<field-validator type="required">
<message>Please enter your message</message>
</field-validator>
</field>
</validators>
If I do not add validation then all is working as it should.
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" namespace="/" extends="struts-default">
<global-results>
<result name="Exception">/error404.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Throwable" result="Exception" />
</global-exception-mappings>
<!-- loads page -->
<action name="main"
class="com.user.action.LoginAction" method="main">
<result name="success">/main.jsp</result>
</action>
<!-- mail action -->
<action name="mail" class="com.user.action.LoginAction" method="mail" >
<result name="success">/main.jsp</result>
</action>
</package>
</struts>
INPUT is one of the predefined results made available by Struts2;
Basically, if your Action sends parameters that are incorrect (conversion errors, like if you send a "abc" to an Integer Action variable), or that don't pass the validation, the Workflow Interceptor return the INPUT result and follow the path specified in the struts configuration for that Action.
Your problem is that you have not defined any INPUT result for your Actions, while you always should.
You can also set a global input result as a fallback, but be careful with that... generally, the page you want to go in case of an INPUT is the same from where the request has been sent.
In case of an INPUT result, your Action method (eg. execute()) is not executed, so if you load common data in that method, like select boxes content, it won't be available anymore.
Read this answers to fully understand what this implies and how to make it work:
How do we repopulate controls when validation fails
Detailed Workflow of the INPUT result processing
I am trying the Data Import Handler for MySQL Database.
I added the DIhandler in solrconfig.xml, created a data-config.xml according to my database scheme and also added a field in the schema.xml which was different. I am connecting with MySQL database
After i connect and I run the dataimport?command=full-import i get this response
"00C:\solr\conf\data-config.xmlfull-importidle1102011-03-05 15:01:04Indexing completed. Added/Updated: 0 documents. Deleted 0 documents.2011-03-05 15:01:042011-03-05 15:01:040:0:0.400This response format is experimental. It is likely to change in the future."
The xml files are in this http://pastebin.com/iKebKGSZ
<field column="manu" name="manu" />
<field column="id" name="id" />
<field column="weight" name="weight" />
<field column="price" name="price" />
<field column="popularity" name="popularity" />
<field column="instock" name="inStock" />
<field column="includes" name="includes" />
Are these fields also in your schema.xml?
I couldnt see them in the pastebin link. Make sure you have all fields in your schema as well.