473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

struts javascript validator message problem

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
5 9706
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
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I...
3
by: sancha | last post by:
Hi, i am in a bit of a delima here. I need to submit an action through javascript so i used document.forms.action='/search.do?&submitaction=Add Minus' document.forms.submit(); since i am...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
1
by: Prasanth Nair | last post by:
hi, When I add the following in struts-config.xml, I am getting the below mentioned error while starting the server. /***********************Struts entry**********************/ <plug-in...
5
by: =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?= | last post by:
Hello, I've been trying to figure something out for the past few days and I can't seem to pinpoint what I'm doing wrong. I've been trying to call javascript from inside a <logic:equal>, but...
1
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader ...
2
by: PaulCarmo | last post by:
Hello, I'm validating a form containing various types of data. One of the fields to be validated is an amount which must be between 0.01 and 999999.99. The code for this field validation in the...
8
by: ajos | last post by:
hi frnds, the situation is im developing a web application in struts-- my specifications-eclipse3.2.2,struts1.1,tomcat5.5.23 mysql5.0 db. the scenario-i have a jsp page which adds the...
1
by: NamelessNumberheadMan | last post by:
I can't seem to get Struts 2 validations to work. I have been converting from Strust 1 to Struts 2. So far I've refactored all the code (for this particular module) on the back end, rewrote the jsp...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.