"I am Having validation.xml given below, what Is the validation-rules.xml for doing Validations In Struts Application - struts

Blockquote
I am Using Following Validation.xml Is It Corret For Doing Validations
For Inputting Name, Age, Email,Telephone In My Struts Application, what is the
validation-rules.xml for it.............................**
Please Help Me.....
Blockquote
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration
1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<global>
<constant>
<constant-name>telephoneFormat</constant-name>
<constant-value>^\d{5,10}$</constant-value>
</constant>
</global>
<formset>
<form name="CustomerForm">
<field property="name" depends="required">
<arg key="label.name" />
</field>
<field property="age" depends="required, integer, intRange">
<arg0 key="label.age" />
<arg1 key="${var:min}" resource="false"/>
<arg2 key="${var:max}" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>1</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>125</var-value>
</var>
</field>
<field property="telephone" depends="required, mask">
<arg key="label.telephone" />
<arg1 key="label.telephone" />
<var>
<var-name>mask</var-name>
<var-value>${telephoneFormat}</var-value>
</var>
</field>
<field property="email" depends="email">
<arg0 key="label.email" />
<arg1 key="label.email" />
</field>
</form>
</formset>
</form-validation>

As far as the validation.xml goes it looks alright to me. I hope you have made the necessary entries in MessageResources.properties file. Unless I'm mistaken you are using the above from another example on the web. I had come across it while searching for something about validation.xml.
If you have any queries do let me know as I have successfully done the validations.

Related

SOLR order/display response fields list in specific way when JSON call?

I have a question about SOLR response fields when JSON response format is obtained.
I have a Web service returning more than 20 fields and they are ordered by default as first the fields having data and after that all other fields.
My question is there a way to precise the order of the fields list, so that we obtain them always in same order ?
Example if I have the fields FIELD 1, FIELD 2, etc, I want that I preserve exactly this order and not FIELD 2, FIELD 1.
Thanks
yes you can precise the order editing the "data-config.xml" , here as you can see are declared all fields and on top are are the corresponding query , delta imports and full import . try to change the fields order in query and declaration in bottom,
example :
<dataConfig>
<dataSource type="HttpDataSource" />
<document>
<entity name="slashdot"
pk="link"
url="http://rss.slashdot.org/Slashdot/slashdot"
processor="XPathEntityProcessor"
forEach="/RDF/channel | /RDF/item"
transformer="DateFormatTransformer">
<field column="source" xpath="/RDF/channel/title" commonField="true" />
<field column="source-link" xpath="/RDF/channel/link" commonField="true" />
<field column="subject" xpath="/RDF/channel/subject" commonField="true" />
<field column="title" xpath="/RDF/item/title" />
<field column="link" xpath="/RDF/item/link" />
<field column="description" xpath="/RDF/item/description" />
<field column="creator" xpath="/RDF/item/creator" />
<field column="item-subject" xpath="/RDF/item/subject" />
<field column="slash-department" xpath="/RDF/item/department" />
<field column="slash-section" xpath="/RDF/item/section" />
<field column="slash-comments" xpath="/RDF/item/comments" />
<field column="date" xpath="/RDF/item/date" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss" />
</entity>
</document>

How can I delete window action in Odoo?

I have created one module in that I have added window action and now in another module I would like to remove that window action. Is there any way to remove / Hide window action ?
Let say following is the action available in sale base module and I would like to remove it in my custom module.
<record id="action_view_sale_advance_payment_inv" model="ir.actions.act_window">
<field name="name">Invoice Order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.advance.payment.inv</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="groups_id" eval="[(4,ref('sales_team.group_sale_salesman'))]"/>
</record>
<!-- TODO: check if we need this -->
<record model="ir.values" id="sale_order_line_make_invoice">
<field name="model_id" ref="sale.model_sale_order_line" />
<field name="name">Invoice Orders</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_sale_advance_payment_inv'))" />
<field name="key">action</field>
<field name="model">sale.order</field>
</record>
I've tested and it works. You just need to delete this ir.value record
self.env.ref('sale.sale_order_line_make_invoice').unlink()
and dropdown is empty
To make it happen automatically you need to make this changes:
create xml
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<function model="*model_name*" name="_test_function"/>
</data>
</openerp>
create model with this function
#api.model
def _test_function(self):
self.env.ref('sale.sale_order_line_make_invoice').unlink()
Good Luck
You can delete the ir.values record, which is "creating" this action. There are 2 (and some more ofcourse) possibilities to do that.
Deleting by using xml/external ID
Condition: The ir.values record have to have an external ID. The deleting module needs the other one as dependency.
<odoo>
<data>
<delete model="ir.values" id="my_module.my_ir_values_id" />
</data>
</odoo>
Deleting by searching
Condition: You need something to search the record for example the name.
<odoo>
<data>
<delete model="ir.values" search="[('name', '=', 'Invoice Order')]" />
</data>
</odoo>

DeltaImport not happening by default

I'm having issues with deltaquery where it's doesn't work automatically. Below is the data-config I have
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://WTL-sql-1.com;databaseName=eng_metrics"
user="metrics"
password="metrics"/>
<document name="content">
<entity name="id"
query="select defect_id,headline,description,modify_date,issue_type,category,product,state FROM defects WHERE state not like 'Duplicate'"
deltaImportQuery="select defect_id,headline,description,modify_date,issue_type,category,product,state FROM defects WHERE defect_id = '${dataimporter.delta.defect_id}' and state not like 'Duplicate'"
deltaQuery="select defect_id FROM defects WHERE modify_date > '${dataimporter.last_index_time}'">
<field column="defect_id" name="defect_id" />
<field column="headline" name="headline" />
<field column="description" name="description" />
<field column="modify_date" name="modify_date" />
<field column="issue_type" name="issue_type" />
<field column="category" name="category" />
<field column="product" name="product" />
<field column="state" name="state" />
</entity>
</document>
</dataConfig>
But what I see that no matter the modify_date changes in the DB, I don't see any update happening unless I try doing a delta import explicitly.
Can someone provide me some thoughts on whether I need to change some config or some query to make that happen automatically?
Actually, DataImportHandler will not do it automatically. You have to trigger it by call delta import 's url.
You may want something like this:
http://wiki.apache.org/solr/DataImportHandler#Scheduling
or you can implement similar one by youself.
But I've this data-config which works fine in some cases
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://127.0.0.1\SQLEXPRESS;databaseName=sustaining_trends"
user="sa"
password="metrics"/>
<document name="content">
<entity name="id"
query="select id,createtime,lastmodified,modifiedby,title,keywords,general,symptom,diagnosis,resolution FROM trends"
deltaImportQuery="select id,createtime,lastmodified,modifiedby,title,keywords,general,symptom,diagnosis,resolution FROM trends WHERE id = ${dataimporter.delta.id}"
deltaQuery="select id FROM trends WHERE lastmodified > '${dataimporter.last_index_time}' or createtime > '${dataimporter.last_index_time}'">
<field column="id" name="trendid" />
<field column="lastmodified" name="lastmodified" />
<field column="modifiedby" name="modifiedby" />
<field column="title" name="title" />
<field column="keywords" name="keywords" />
<field column="general" name="general" />
<field column="symptom" name="symptom" />
<field column="diagnosis" name="diagnosis" />
<field column="resolution" name="resolution" />
</entity>
</document>
</dataConfig>
Here if the item is modified immediately that gets updated without any interference but if a new data is created that doesn't get updated until either I do a manual delta import or else some entry gets modified.
How does this work automatically incase of modification and not work automatically for creation?

The content of element type "formset" must match "(constant*,form+)"

I am getting error as
The content of element type "formset" must match "(constant*,form+)"
while I am executing my struts application it will give error as below:
2013-09-27 15:22:35 ERROR org.apache.commons.digester.Digester - Parse Error at line 203 column 15: The content of element type "formset" must match "(constant*,form+)".
org.xml.sax.SAXParseException; lineNumber: 203; columnNumber: 15; The content of element type "formset" must match "(constant*,form+)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1666)
at org.apache.commons.validator.ValidatorResources.<init>(ValidatorResources.java:159)
at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:237)
at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:162)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5001)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5289)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I have wriiten validation.xml file as below.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<global>
</global>
<formset>
<form name="logonForm">
<field
property="username"
depends="registerrequired">
<arg key="logonForm.username"/>
</field>
</form>
<form name="attachdynamicLookupForm">
<field
property="theFile"
depends="registerrequired">
<arg key="attachdynamicLookupForm.to"/>
</field>
</form>
<form name="UserFormBean">
<field
property="username"
depends="required">
<arg key="userbean.username"/>
</field>
<field
property="firstname"
depends="required">
<arg key="userbean.firstname"/>
</field>
<field
property="lastname"
depends="required">
<arg key="userbean.lastname"/>
</field>
<field
property="address"
depends="required">
<arg key="userbean.address"/>
</field>
<field
property="city"
depends="required">
<arg key="userbean.city"/>
</field>
<field
property="postcode"
depends="required,mask">
<msg name="mask" key="userbean.postcode.mask"/>
<arg key="userbean.postcode"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]{6}</var-value>
</var>
</field>
<field
property="mobileno"
depends="required,mask">
<msg name="mask" key="userbean.mobile.mask"/>
<arg key="userbean.mobileno"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9]{12}</var-value>
</var>
</field>
<field
property="email"
depends="required,email">
<arg key="userbean.email"/>
</field>
</form>
<form name="DynaUpdateContactForm">
<field
property="contactName"
depends="registerrequired">
<arg key="dynaupdatecontact.contactname"/>
</field>
<field
property="contactNumber"
depends="registerrequired,phone">
<arg key="dynaupdatecontact.contactnumber"/>
</field>
</form>
<!-- resetpassword form -->
<form name="DynaResetPassActionForm">
<field
property="username"
depends="registerrequired">
<arg key="resetpass.username"/>
</field>
<field
property="newpass"
depends="registerrequired,mask">
<arg key="resetpass.newpass"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
<field
property="conpass"
depends="registerrequired,mask">
<arg key="resetpass.conpass"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
<!-- changepassword form -->
<form name="DynaChangePassActionForm">
<field
property="oldpassword"
depends="registerrequired">
<arg key="changepass.oldpass"/>
</field>
<field
property="newpass"
depends="registerrequired,mask">
<arg key="changepass.newpass"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
<field
property="conpass"
depends="registerrequired,mask">
<arg key="changepass.conpass"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
<form name="DynaUpdateSenderNameActionForm">
<field
property="newsendername"
depends="registerrequired">
<arg key="dynaupdatesendername.newsender"/>
</field>
</form>
///////////////////
<form name="DynaSMSRequestActionForm">
<field
property="req"
depends="registerrequired,mask">
<arg key="smsrequest.request"/>
<var>
<var-name>mask</var-name>
<var-value>^[ 0-9]+$</var-value>
</var>
</field>
</form>
</formset>
<!-- An example formset for another locale -->
<formset language="fr">
<constant>
<constant-name>postalCode</constant-name>
<constant-value>^[0-9a-zA-Z]*$</constant-value>
</constant>
<!-- An example form -->
<form name="logonForm">
<field
property="username"
depends="required">
<arg key="logonForm.username"/>
</field>
<field
property="password"
depends="required,mask">
<arg key="logonForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
You probably have another file in your path that matches the naming criteria for a validator.
Most probably you are having trouble due to your "////" at this
///////////////////
<form name="DynaSMSRequestActionForm">
You should remove those from code and try again. Hope this helps.
if you see below example compare that with your xml file in that you missed <var-jstype> inside <var>
Please try this.
<field property="id" depends="intRange">
<arg key="id" resource="false" />
<arg key="${var:min}" resource="false" />
<arg key="${var:max}" resource="false" />
<var>
<var-name>min</var-name>
<var-value>10</var-value>
<var-jstype></var-jstype>
</var>
</field>

How to trigger checkboxes with XFDF

Here is what I have:
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<fields>
<field name="text1">
<value>First Last</value>
<field name="checkbox1">
<value>yes</value>
</field>
<field name="checkbox2">
<value></value>
</field>
<ids original="xxxxx" modified="1331062234" />
<f href="http://example.com/test.pdf" />
</xfdf>
The text value gets entered in the PDF, but I can't figure out how to get the checkboxes to recognize that they are checked.
<input type="checkbox" name="checkbox_name" value="yes" />
The xfdf value entry needs to match the checkbox value:
<field name="checkbox_name">
<value>yes</value>
</field>