Hi,
We need some advice on validation in Jahia, specifically conditional
validation of a Jahia container.
Validation seems to be done with Struts Validation rules. OK. I've
done that in systems of my own in the past.
We've been able to make validation work for simple rules in Jahia such
as "is a field required or not"
However, if we want to make a field required conditionally, we've run
into some strange problems.
It seems that if you use the "validwhen" argument, it works the first
time in that Jahia stops you and displays your validation message
(such as "x is required when y is foo").
But, if you put in the valid text and click OK it should pass
validation, create the record and close the Content Object window.
Instead, it reloads the pages and continues to display the validation
message.
Has anyone come across this? Has anyone tried to do conditional
validation of fields in Jahia?
Also notice below that the expression we are trying to validate is :
(docODS != 'Link')
In theory, it should be this (in our mind):
(docODS == 'Link')
However, we had to reverse it to get the expected validation message.
We don't know why.
Please help. This is very frustrating.
===========================
excerpted from our Struts validation XML file:
===========================
<form name="docBean">
<field property="docName" depends="required">
<arg0 key="label.doc.name"/>
</field>
<field property="docSymb" depends="required">
<arg0 key="label.doc.symb"/>
</field>
<field property="docDate" depends="required">
<arg0 key="label.date"/>
</field>
<field property="docLink" depends="validwhen">
<arg0 key="label.doc.link"/>
<var>
<var-name>test</var-name>
<var-value>(docODS != 'Link')</var-value>
</var>
</field>
</form>
===========================
Definition of our container (it's a child of box from corp v2 templates)
===========================
<content:declareContainerList
name='<%="docs" + id%>' title="Documents"
titleKey="boxContainer.docsContainer" bundleKey="<%=resBundleID%>"
aliasNames="boxDocs" validatorKey="docBean"
containerBeanName="jahiatemplates.org.foo.pojo.DocBean"
>
<content:declareContainer>
<content:declareField name="docName"
title="Document Name" type="SmallText"
titleKey="boxContainer.docs.name" bundleKey="<%=resBundleID%>"
aliasNames="boxDoc"
/>
<content:declareField name="docSymb"
title="Document Symbol" type="SmallText"
titleKey="boxContainer.docs.symb" bundleKey="<%=resBundleID%>"
aliasNames="boxDocSymb"
/>
<content:declareField name="docDesc"
title="Description" type="SmallText"
titleKey="boxContainer.docs.desc" bundleKey="<%=resBundleID%>"
aliasNames="boxDocDesc"
/>
<content:declareField name="docDate"
title="Date Issued" type="Date"
titleKey="boxContainer.docs.date" bundleKey="<%=resBundleID%>"
aliasNames="boxDocDate"
/>
<content:declareField name="docODS"
title="Link Type" type="SmallText"
value="<jahia_multivalue[ODS:File:Link]>ODS"
titleKey="boxContainer.docs.ODS" bundleKey="<%=resBundleID%>"
aliasNames="boxDocODS"
/>
<content:declareField name='docLink'
title="Document Link" type="SmallText"
titleKey="boxContainer.docs.link" bundleKey="<%=resBundleID%>"
value="<linkonly,external>"
aliasNames="boxDocLink"
/>
<content:declareField name="docFile"
title="Document File" type="File"
titleKey="boxContainer.docs.file" bundleKey="<%=resBundleID%>"
aliasNames="boxDocFile"
/>
</content:declareContainer>
</content:declareContainerList>
===========================
Thanks for any information you can provide.
Kevin
_______________________________________________
template_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list