By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

struts javascript validator message problem

P: n/a
I'm trying to use the jakarta struts client side javascript validators
and the validators are working, but they are not showing the popup
messages. I have the message keys defined in the
ApplicationResources.properties file, the propertise file is in the
right location, it is referenced from the struts-config.xml, but still
no messages. For example, submitting a form that violates the
required field validator, just causes it to do nothing but shift focus
to that field, no messages are shown.

Am I missing something?
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Alex M wrote:
I'm trying to use the jakarta struts client side javascript validators
and the validators are working, but they are not showing the popup
messages. I have the message keys defined in the
ApplicationResources.properties file, the propertise file is in the
right location, it is referenced from the struts-config.xml, but still
no messages. For example, submitting a form that violates the
required field validator, just causes it to do nothing but shift focus
to that field, no messages are shown.

Am I missing something?


javascript? This is the java newsgroup - try posting that to
comp.lang.javascript instead.
Jul 17 '05 #2

P: n/a
Peter Astbury wrote:
Alex M wrote:
I'm trying to use the jakarta struts client side javascript validators
and the validators are working, but they are not showing the popup
messages. I have the message keys defined in the
ApplicationResources.properties file, the propertise file is in the
right location, it is referenced from the struts-config.xml, but still
no messages. For example, submitting a form that violates the
required field validator, just causes it to do nothing but shift focus
to that field, no messages are shown.

Am I missing something?


javascript? This is the java newsgroup - try posting that to
comp.lang.javascript instead.


He is right to post here, this is a Struts question. As it is, I don't know
the answer since I've only used the server-side validator component, not
the client-side component. Maybe someone else will have an idea.

OS, browser etc would be some useful information...

Matt

--
Not so interesting...
http://www.mpcontracting.co.uk
Jul 17 '05 #3

P: n/a
"Alex M" <al*@acm.org> wrote in message
news:ac**************************@posting.google.c om...
I'm trying to use the jakarta struts client side javascript validators
and the validators are working, but they are not showing the popup
messages. I have the message keys defined in the
ApplicationResources.properties file, the propertise file is in the
right location, it is referenced from the struts-config.xml, but still
no messages. For example, submitting a form that violates the
required field validator, just causes it to do nothing but shift focus
to that field, no messages are shown.

Am I missing something?


Do you have all the javascript elements and files in the proper places? I'm
learning Struts now and just tinkered with that feature yesterday. If you
look at the example application that comes with it, you'll see an example of
Javascript validation in their logon.jsp. First of all, the Javascript
itself is specified in validator-rules.xml. You need an <html:javascript>
tag in the file where you want to do the validation as well as a script tag
to include an external js file, staticJavascript.jsp (that's their name for
it). See the example app for this file's contents (it's tiny, not sure how
it does what it does yet). Finally, in the form you want to validate add to
the form tag:
onsubmit="return validateLogonForm(this);"

Or whatever function you want to call. I think that's everything.
Jul 17 '05 #4

P: n/a
Hi
I have the same frustrating problem. I fix it with the following
code in validation.xml. Not neat, Strangly,
<arg0 key="error.username.required"/> doesn't work. Probabably
a bug.

<form-validation>
<formset>
<form name="logonForm">
<field property="username" depends="required,maxlength">
<msg name="required" key="error.username.required"/>
<msg name="maxlength" key="error.maxlength"/>
<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>
<field property="password" depends="required">
<msg name="required" key="error.password.required"/>
</field>
</form>
</formset>
</form-validation>

<!-- doesn't work

<form-validation>
<formset>
<form name="logonForm">
<field property="username" depends="required">
<arg0 key="error.username.required"/>
</field>
<field property="password" depends="required">
<arg0 key="error.password.required"/>
</field>
</form>
</formset>
</form-validation>

-->
Regards

StrutsMan
Jul 17 '05 #5

P: n/a
Nam
you can use regexp package from apache.org. it is great.

st*******@slingshot.co.nz (strutsman) wrote in message news:<f6**************************@posting.google. com>...
Hi
I have the same frustrating problem. I fix it with the following
code in validation.xml. Not neat, Strangly,
<arg0 key="error.username.required"/> doesn't work. Probabably
a bug.

<form-validation>
<formset>
<form name="logonForm">
<field property="username" depends="required,maxlength">
<msg name="required" key="error.username.required"/>
<msg name="maxlength" key="error.maxlength"/>
<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>
<field property="password" depends="required">
<msg name="required" key="error.password.required"/>
</field>
</form>
</formset>
</form-validation>

<!-- doesn't work

<form-validation>
<formset>
<form name="logonForm">
<field property="username" depends="required">
<arg0 key="error.username.required"/>
</field>
<field property="password" depends="required">
<arg0 key="error.password.required"/>
</field>
</form>
</formset>
</form-validation>

-->
Regards

StrutsMan

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.