Thanks a lot for your help.
Unfortunately, there's still something i can't get...
I closely looked at the wiki
http://rifers.org/wiki/display/RIFE/Validation.
So i changed my code this way :
template :
<!--V 'ERRORS:*'/-->
<form action="[!V 'SUBMISSION:FORM:vip_data'/]" method="post"><!--V
'SUBMISSION:PARAMS:vip_data'/-->
<table>
<tr>
<td><!--V 'L10N:label.firstname'-->d_first name<!--/V--></td>
<td><!--V 'FORM:INPUT:firstName' /--></td>
<td></td>
</tr>
</table>
<input type="submit" value="[!V 'L10N:validate'/]" /></form>
</form>
implementation :
public class InscriptionVIP extends Element {
static Logger logger = Logger.getLogger(InscriptionVIP.class);
public void processElement() {
Template template = getHtmlTemplate("mypackage.inscription_vip");
ResourceBundle bundle = Localization.getResourceBundle("text",
"fr");
template.addResourceBundle(bundle);
VIP vip = (VIP) getNamedSubmissionBean("vip_data", "vip");
if (vip != null) {
Validated v = (Validated) vip;
if (!v.validate()) {
logger.debug("not validated");
ValidationBuilderXhtml builder = new
ValidationBuilderXhtml();
builder.setFallbackErrorArea(template,
"The first name is not valid.");
} else {
logger.debug("validated");
}
v.resetValidation();
}
print(template);
}
}
This way, my sample works great.
But i still can not make it work this way :
template :
<!--B 'ERRORS:firstName'-->
The first name is not valid.
<!--/B-->
<form action="[!V 'SUBMISSION:FORM:vip_data'/]" method="post"><!--V
'SUBMISSION:PARAMS:vip_data'/-->
<table>
<tr>
<td><!--V 'L10N:label.firstname'-->d_first name<!--/V--></td>
<td><!--V 'FORM:INPUT:firstName' /--></td>
<td><!--V 'ERRORS:firstName'/--></td>
</tr>
</table>
<input type="submit" value="[!V 'L10N:label.validate'/]" /></form>
</form>
implementation :
public class InscriptionVIP extends Element {
static Logger logger = Logger.getLogger(InscriptionVIP.class);
public void processElement() {
Template template = getHtmlTemplate("mypackage.inscription_vip");
ResourceBundle bundle = Localization.getResourceBundle("text",
"fr");
template.addResourceBundle(bundle);
VIP vip = (VIP) getNamedSubmissionBean("vip_data", "vip");
if (vip != null) {
Validated v = (Validated) vip;
if (!v.validate()) {
logger.debug("not validated");
generateForm(template, vip);
} else {
logger.debug("validated");
}
v.resetValidation();
}
print(template);
}
}
I still get the following error message :
com.uwyn.rife.template.exceptions.ValueUnknownException: The template
doesn't contain a value with id 'ERRORS'.
at
com.uwyn.rife.template.AbstractTemplate.setValue(AbstractTemplate.java:496)
at
com.uwyn.rife.site.AbstractValidationBuilder.generateValidationErrors(AbstractValidationBuilder.java:410)
at
com.uwyn.rife.site.FormBuilderXhtml.generateForm(FormBuilderXhtml.java:112)
at
com.uwyn.rife.site.FormBuilderXhtml.generateForm(FormBuilderXhtml.java:60)
at
com.uwyn.rife.engine.ElementContext.generateForm(ElementContext.java:3151)
at
com.uwyn.rife.engine.ElementSupport.generateForm(ElementSupport.java:4735)
at
com.uwyn.rife.engine.ElementSupport.generateForm(ElementSupport.java:4703)
at
mypackage.inscription.InscriptionVIP.processElement(InscriptionVIP.java:32)
at
com.uwyn.rife.engine.ElementContext.processContext(ElementContext.java:587)
at com.uwyn.rife.engine.RequestState.service(RequestState.java:212)
at com.uwyn.rife.engine.Gate.handleRequest(Gate.java:416)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.uwyn.rife.servlet.RifeFilter.doFilter(RifeFilter.java:127)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Thanks for your help.
Laki
Geert Bevin wrote:
Hey guys,
The "<!--V 'FORM:INPUT:firstName' /-->" did it for retaining the
field value.
Yes, It is generated by RIFE and retain value.
Just clarifying something here.
The <!--V 'FORM:INPUT:firstName'/--> tag generates an entire form
input tag from constraints, and populates it with the current value
from the bean property. If you're just interested in filling in the
parameter value that was submitted, you can use this too: <input
type="text" name="firstName" length="51"
maxlength="50" value="[!V 'PARAM:firstName'][!/V]" />
I prefer the first one though, since it generates everything
according to the constraints.
Best regards,
Geert
--Geert Bevin Uwyn bvba GTalk:
[EMAIL PROTECTED]
"Use what you need" Avenue de Scailmont 34 Skype: gbevin
http://www.uwyn.com 7170 Manage, Belgium AIM: geertbevin
gbevin at uwyn dot com Tel: +32 64 84 80 03 Mobile: +32 477 302 599
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users