Author Login
Post Reply
user Digest 25 Jun 2008 22:27:06 -0000 Issue 8109
Topics (messages 188081 through 188105):
Struts list
188081 by: Sonu S
Re: Struts2 UI Tag HTML Compliance?
188082 by: Jeromy Evans
namespace getting appended to servletPath
188083 by: Dwipin C
188085 by: Jeromy Evans
Avoid having an action property called id
188084 by: Jonny Cavell
188086 by: Mark Menard
Newbie: Call a servlet in another application and set attribute
188087 by: Mustafa Cayci
188088 by: Dave Newton
188089 by: Marc Ende
188090 by: Mustafa Cayci
188091 by: Dave Newton
188092 by: Nils-Helge Garli Hegvik
Re: [struts] Slow performance with Struts2
188093 by: Dale Newfield
Re: validation problem
188094 by: Istvan Kozma
188095 by: Lukasz Lenart
188096 by: Dave Newton
weird problem in <s:iterator>
188097 by: sharath karnati
188099 by: Lukasz Lenart
Struts 2 And Hibernate Problem
188098 by: cree
weird problem <s:iterator> tag.
188100 by: sharath karnati
188101 by: Lukasz Lenart
188102 by: Pawe³ Wielgus
188104 by: sharath karnati
188105 by: sharath karnati
Re: Struts Validator Framework: problem with Custom Validator
188103 by: cacodemon79
Administrivia:
---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)
----------------------------------------------------------------------

Attachment:
user_188081.ezm (zipped) HI,
I have to show list in my jsp page. I am using <html:select>
i am getting two lists from data base and it is in employee form bean: first
list is for employee no and second list is for name. i want to display
employee name in <option> and want to use employee no as VALUE in <option>
so list would have employee no as value and name will be displayed to user.
i am not sure how to do it with two lists as i have two different lists, one
list for emp no and one list for employee name. My form bean name is
employeeForm and list names are employeeNoList and employeeNameList. Please
help me... some code example would be a help for me. I am using struts 1.1
Thank you

Attachment:
user_188082.ezm (zipped)albertooi wrote:
> Anyone aware if the Struts2 UI tags are HTML compliant? Which version of HTML
> Specs? E.g 4.x? Need to ascertain which browser is supported if struts2 ui
> tags are being used.
>
generally html 4.x but I don't think they validate. Definitely not
xhtml, no features of 5.x.
More importantly, the "xhtml theme" uses tables for layout, the
"css_xhtml theme" uses divs, spans and css2 for layout, the "simple
theme" outputs plain-old html 4 with no markup for layout and you can
customize the theme for every tag.
Hope that helps.
Jeromy Evans

Attachment:
user_188083.ezm (zipped)Hi,
I have used a namespace "abc" for a particular set of action
classes. The action class invocation happens with the namespace in the
requested url, as expected. However after the processing is done, the
namespace is appended to the result jsp.
code snippet -
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="pack1" namespace="/u"
extends="default">
<action name="Login_*" method="{1}"
class="com.LoginAction">
<result
name="input">WEB-INF/jsp/Login.jsp</result>
<result
name="FIRST">WEB-INF/jsp/Login.jsp</result>
<result name="EXPIRED_PASSWORD">
WEB-INF/jsp/ChangePassword.jsp
</result>
<interceptor-ref name="basic" />
</action>
After processing, the servletPath is "/u/WEB-INF/jsp/Login.jsp" . Is this
the expected behavior? I would prefer not changing my jsp location.
Any pointers would be of great help.
Thanks,
Dwipin Chandran.
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you

Attachment:
user_188085.ezm (zipped)Dwipin C wrote:
> <result name="EXPIRED_PASSWORD">
> WEB-INF/jsp/ChangePassword.jsp
>
Include a / in front of WEB-INF. (/WEB-INF/jsp/ChangePassword.jsp)
S2 forwards to the JSP result and without the leading slash the
container assumes it's a path relative to your package namespace

Attachment:
user_188084.ezm (zipped)
This http://www.vitarara.org/cms/struts_2_cookbook/post_and_redirect article
about post and redirect in struts 2 explains how to redirect to a
dynamically evaluated action.
However, if I use a param which references an action property called "id",
it doesn't work.
<result type="redirect-action">
<param name="actionName">${redirectActionName}</param>
<param name="namespace">/admin/holidays</param>
<param name="parse">true</param>
<param name="id">${id}</param>
</result>
But when I changed the property (and its getter and setter) to be called
"aid", it works OK:
<result type="redirect-action">
.. as above...
..............
<param name="id">${aid}</param>
</result>
Also (possibly unrelated), again with a property called id on my action,
when I use the <s:url> tag, it automatically adds the current value of
the action's id to the URL even if I don't want it to. The docs don't
mention that this should happen (it's annoying).
It seems as if naming an action property id should be avoided...
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_188086.ezm (zipped)Hi Jonny,
I have id properties on actions all over my application.
I also have several actions that do a redirect to id. I think there's
something wrong with either your environment or your action that's causing
the issue.
What exactly happens when it doesn't work?
Mark
The guy who wrote the article.
On 6/25/08 11:29 AM, "Jonny Cavell" <jonny.cavell@(protected):
>
> This http://www.vitarara.org/cms/struts_2_cookbook/post_and_redirect article
> about post and redirect in struts 2 explains how to redirect to a
> dynamically evaluated action.
>
> However, if I use a param which references an action property called "id",
> it doesn't work.
>
> <result type="redirect-action">
> <param name="actionName">${redirectActionName}</param>
> <param name="namespace">/admin/holidays</param>
> <param name="parse">true</param>
> <param name="id">${id}</param>
> </result>
>
> But when I changed the property (and its getter and setter) to be called
> "aid", it works OK:
> <result type="redirect-action">
> .. as above...
> ..............
> <param name="id">${aid}</param>
> </result>
>
>
> Also (possibly unrelated), again with a property called id on my action,
> when I use the <s:url> tag, it automatically adds the current value of
> the action's id to the URL even if I don't want it to. The docs don't
> mention that this should happen (it's annoying).
>
> It seems as if naming an action property id should be avoided...

Attachment:
user_188087.ezm (zipped)Hello,
I am fairly new to Struts. I have two applications. AppA is a Struts application and AppB is another application. I have an Action class in AppA. Within execute() method, I am creating some objects. I would like to call the servlet in AppB and somehow I want to pass these objects to the servlet in AppB. SO far I have this
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
...
response.sendRedirect("/testsqlservlet/testsqlservlet?Object=" + object);
...
But this is a problem because even if I use SSL (i.e. https://) this redirect will be in cleartext and anybody can modify the "object". What are my options? I am hope I explained myself clearly.
Thanks,
Mustafa

Attachment:
user_188088.ezm (zipped)--- On Wed, 6/25/08, Mustafa Cayci <acayci@(protected):
> I am fairly new to Struts. I have two applications. AppA
> is a Struts application and AppB is another application. I
> have an Action class in AppA. Within execute() method, I am
> creating some objects. I would like to call the servlet in
> AppB and somehow I want to pass these objects to the
> servlet in AppB. SO far I have this
>
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,
> HttpServletRequest
> request,
> HttpServletResponse
> response) throws Exception {
> ...
>
> response.sendRedirect("/testsqlservlet/testsqlservlet?Object="
> + object);
> ...
>
> But this is a problem because even if I use SSL (i.e.
> https://) this redirect will be in cleartext and anybody
> can modify the "object". What are my options? I
> am hope I explained myself clearly.
Put it in the session?
That's not passing the object, either; that's passing the string representation of the object. A bit different.
Dave

Attachment:
user_188089.ezm (zipped)Hi Mustafa,
if I understand you correctly you're trying to pass an object in another
webapp. That's not a really struts-usecase. I think you're looking for
a webservice or another kind of procedurecalls (like rmi).
I think you should look for axis, cxf or another project which are more
helpful for this kind of uses.
Marc
Am Mittwoch, den 25.06.2008, 09:27 -0700 schrieb Mustafa Cayci:
> I am fairly new to Struts. I have two applications. AppA is a Struts application and AppB is another application. I have an Action class in AppA. Within execute() method, I am creating some objects. I would like to call the servlet in AppB and somehow I want to pass these objects to the servlet in AppB. SO far I have this
>
> public ActionForward execute(ActionMapping mapping, ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response) throws Exception {
> ...
> response.sendRedirect("/testsqlservlet/testsqlservlet?Object=" + object);
> ...
>
> But this is a problem because even if I use SSL (i.e. https://) this redirect will be in cleartext and anybody can modify the "object". What are my options? I am hope I explained myself clearly.

Attachment:
user_188090.ezm (zipped)Hello Dave,
Let me try to understan what you mean. Are you saying that I should be doing this
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
....
HttpSession session = request.getSession();
session.setAttribute("Principal",principal);
response.sendRedirect("/testsqlservlet/testsqlservlet");
...
Because this did not work.
Thanks,
Mustafa
----- Original Message ----
From: Dave Newton <newton.dave@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Wednesday, June 25, 2008 12:58:09 PM
Subject: Re: Newbie: Call a servlet in another application and set attribute
--- On Wed, 6/25/08, Mustafa Cayci <acayci@(protected):
> I am fairly new to Struts. I have two applications. AppA
> is a Struts application and AppB is another application. I
> have an Action class in AppA. Within execute() method, I am
> creating some objects. I would like to call the servlet in
> AppB and somehow I want to pass these objects to the
> servlet in AppB. SO far I have this
>
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,
> HttpServletRequest
> request,
> HttpServletResponse
> response) throws Exception {
> ...
>
> response.sendRedirect("/testsqlservlet/testsqlservlet?Object="
> + object);
> ...
>
> But this is a problem because even if I use SSL (i.e.
> https://) this redirect will be in cleartext and anybody
> can modify the "object". What are my options? I
> am hope I explained myself clearly.
Put it in the session?
That's not passing the object, either; that's passing the string representation of the object. A bit different.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_188091.ezm (zipped)--- On Wed, 6/25/08, Mustafa Cayci <acayci@(protected):
> Let me try to understan what you mean. Are you saying
> that I should be doing this
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,
>
> HttpServletRequest request,
>
> HttpServletResponse response) throws Exception {
> ....
> HttpSession session = request.getSession();
>
> session.setAttribute("Principal",principal);
>
> response.sendRedirect("/testsqlservlet/testsqlservlet");
> ...
> Because this did not work.
If they're actually two different applications, no, it wouldn't work.
Unlike the other reply I had assumed they were in the same app, but apparently you meant what you said. Things don't work like that, on several ways, so you'll have to explore other options.
Dave

Attachment:
user_188092.ezm (zipped)I believe most servlet containers prevent sharing of session objects
between applications by default. But it probably can be configured to
be allowed (consult the documentation for your server to find out
how). A shared cache is also an option. But the easiest would be to
put them in the same application.
Nils-H
On Wed, Jun 25, 2008 at 7:29 PM, Mustafa Cayci <acayci@(protected):
> Hello Dave,
> Let me try to understan what you mean. Are you saying that I should be doing this
> public ActionForward execute(ActionMapping mapping, ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response) throws Exception {
> ....
> HttpSession session = request.getSession();
> session.setAttribute("Principal",principal);
> response.sendRedirect("/testsqlservlet/testsqlservlet");
> ...
> Because this did not work.
> Thanks,
> Mustafa
>
> ----- Original Message ----
> From: Dave Newton <newton.dave@(protected)>
> To: Struts Users Mailing List <user@(protected)>
> Sent: Wednesday, June 25, 2008 12:58:09 PM
> Subject: Re: Newbie: Call a servlet in another application and set attribute
>
> --- On Wed, 6/25/08, Mustafa Cayci <acayci@(protected):
>> I am fairly new to Struts. I have two applications. AppA
>> is a Struts application and AppB is another application. I
>> have an Action class in AppA. Within execute() method, I am
>> creating some objects. I would like to call the servlet in
>> AppB and somehow I want to pass these objects to the
>> servlet in AppB. SO far I have this
>>
>> public ActionForward execute(ActionMapping mapping,
>> ActionForm form,
>> HttpServletRequest
>> request,
>> HttpServletResponse
>> response) throws Exception {
>> ...
>>
>> response.sendRedirect("/testsqlservlet/testsqlservlet?Object="
>> + object);
>> ...
>>
>> But this is a problem because even if I use SSL (i.e.
>> https://) this redirect will be in cleartext and anybody
>> can modify the "object". What are my options? I
>> am hope I explained myself clearly.
>
> Put it in the session?
>
> That's not passing the object, either; that's passing the string representation of the object. A bit different.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_188093.ezm (zipped)yorlick kilroy wrote:
> Still... the "problem" seems to be the OGNL implementation in struts2.
I'm guessing here, but maybe your issues are related to:
http://jira.opensymphony.com/browse/OGNL-141
Which has been pushed off in Xwork to 2.5:
http://jira.opensymphony.com/browse/XW-631
And which has been pushed off in Struts2 until at least 2.1.3:
https://issues.apache.org/struts/browse/WW-2128
You're welcome to update the version of ognl you're using in your own
app (but remember to add javassist if so).
> <s:iterate ... >
> <s:property value="#object.a.b.c.name"/>
> <s:property value="#object.a.b.c.phone"/>
> </s:iterate>
Theoretically this translates to a straight lookup for #object, then
getA().getB().getC().getName()...
If A, B, and C are just accessors, it should be fast. If they do much
work to determine what to return, you're doing that work 2*N times
(where N is the number of times through the loop) instead of just
once...why would you put a long lookup like that in an iterator if it
doesn't change with each iteration?
-Dale

Attachment:
user_188094.ezm (zipped)Hi,
How the validation should be done for fields which are only displayed in certain conditions? If I do this through the XML file the validation is done all the time even when the field is not visible.
Istvan
----- Original Message ----
From: Dave Newton <newton.dave@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Wednesday, June 25, 2008 3:37:38 PM
Subject: Re: validation problem
Whoops, as the other reply said, it's the <s:fielderror...> tag [1], not <s:actionerror>.
Dave
[1] http://struts.apache.org/2.x/docs/fielderror.html
--- On Wed, 6/25/08, Dave Newton <newton.dave@(protected):
> --- On Wed, 6/25/08, Anshu Dhamija wrote:
> > i am facing problem in performing validation through
> > xml actually i want to display message at the top of
> > my form instaed of at field level
> > can anyone please help me
>
> The validation messages are placed in the form by the S2
> form element tags. If you want to modify the output of
> those tags you can modify or create a theme [1].
>
> Using the "simple" theme will also remove the
> validation messages, but you'll lose other useful
> functionality--but that might not be an issue depending on
> your usecase.
>
> The <s:actionerror...> tag [2] will render any error
> messages. A combination of either the simple theme or a
> modified theme plus the action error tag may do what you
> need.
>
> Dave
>
> [1]
> http://struts.apache.org/2.x/docs/themes-and-templates.html
> [2] http://struts.apache.org/2.x/docs/actionerror.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_188095.ezm (zipped)Hi,
> How the validation should be done for fields which are only displayed in certain conditions? If I do this through the XML file the validation is done all the time even when the field is not visible.
You can implement validate() or validate<ActionAlias>() and remember
to implement Validatable interface.
http://struts.apache.org/2.1.2/docs/validation.html
Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment:
user_188096.ezm (zipped)You either do conditional validations, implement custom validators, or as Lukasz suggested write your own validate() method. When validation is very complex the last may be the best options.
Dave
--- On Wed, 6/25/08, Istvan Kozma <kozma_istvan@(protected):
> How the validation should be done for fields which are only
> displayed in certain conditions? If I do this through the
> XML file the validation is done all the time even when the
> field is not visible.
>
> Istvan
>
>
> ----- Original Message ----
> From: Dave Newton <newton.dave@(protected)>
> To: Struts Users Mailing List
> <user@(protected)>
> Sent: Wednesday, June 25, 2008 3:37:38 PM
> Subject: Re: validation problem
>
> Whoops, as the other reply said, it's the
> <s:fielderror...> tag [1], not <s:actionerror>.
>
> Dave
>
> [1] http://struts.apache.org/2.x/docs/fielderror.html
>
> --- On Wed, 6/25/08, Dave Newton
> <newton.dave@(protected):
> > --- On Wed, 6/25/08, Anshu Dhamija wrote:
> > > i am facing problem in performing validation
> through
> > > xml actually i want to display message at the top
> of
> > > my form instaed of at field level
> > > can anyone please help me
> >
> > The validation messages are placed in the form by the
> S2
> > form element tags. If you want to modify the output of
> > those tags you can modify or create a theme [1].
> >
> > Using the "simple" theme will also remove
> the
> > validation messages, but you'll lose other useful
> > functionality--but that might not be an issue
> depending on
> > your usecase.
> >
> > The <s:actionerror...> tag [2] will render any
> error
> > messages. A combination of either the simple theme or
> a
> > modified theme plus the action error tag may do what
> you
> > need.
> >
> > Dave
> >
> > [1]
> >
> http://struts.apache.org/2.x/docs/themes-and-templates.html
> > [2] http://struts.apache.org/2.x/docs/actionerror.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail:
> user-help@(protected)

Attachment:
user_188097.ezm (zipped)Hi All,
In .jsp file, I'm having following <s:iterator> tag
<s:iterator value="userCommentsList" id="usercomment">
<tr>
<td align="center"> <s:property value="#usercomment.projectNm" /> </td>
<td align="center"> <s:property value="#usercomment.subject" /> </td>
<td align="center"> <s:property value="#usercomment.comments" /> </td>
<c:if test="${deploymentVersion!='All'}">
<td align="center"> <s:date name="#usercomment.closingDate" format="MM/dd/yyyy" /> </td>
</c:if>
</tr>
</s:iterator>

Attachment:
user_188099.ezm (zipped)And the problem is?
Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment:
user_188098.ezm (zipped)
Hello,
I recently have been working on a struts 2 + spring 2 + hibernate system and
have come across a problem that I never have when just working on a struts 2
system.
I have two action classes, one that prepares the jsp and populates some
selects for the user to choose from, and another that takes and processes
the information. When the first action is invoked the result will bring it
to the tiles (type="tiles") on the struts.xml file. The second action will
take the form information and do a search, in this instance I am using
hibernate to access the db.
I would do the search and when I get the list of persistent values I would
chain (type="chain") to the first action class with the list of persistent
objects and would then return to the tiles and the jsp showing the values
that I found on the search.
The problem I am having here is that because of the chain (or similarly a
redirect action), the list of persistent objects will re-appear if I went
off to some other action classes and came back. What I mean by that is if I
had a list of 10 values that I searched for and displayed them, if I went
to some other jsp/action class and came back to that same one the same exact
10 values are being populated.
At that point when I would return to the original jsp the value stack should
have removed them completely, which it has. There is no trace of the list
of persistent objects on the value stack as well as not being a cache
problem. The situation arises when the chain occurs, I have worked with
just a struts 2 system for a year now and never had this problem. I know
this is the case because when I get rid of the chain and invoke the tiles
from the second action class the problem goes away.
I am not too sure why these values persist throughout the session and why
they re-appear even though they are not on value stack. I have found a very
similar problem in which this person found that the problem occured during
an action redirect at
http://www.nabble.com/Struts-2-%2B-Hibernate-question-td17527841.html
http://www.nabble.com/Struts-2-%2B-Hibernate-question-td17527841.html
On a side note, just remembered, when I would want to populate the list
after its already been populated (so the user will search once then decide
to search again) the values wouldnt change even after setting it to a new
list. If I set that list to null first then changed it, the values would
change, not sure if that makes much sense.
If anyone has an idea on what can be causing this I would greatly appretiate
your help.
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_188100.ezm (zipped)Hi All,
In .jsp file, I'm having following code which is using <s:iterator> tag.
<s:iterator value="userCommentsList" id="usercomment">
<tr>
<td align="center"> <s:property value="#usercomment.projectNm" /> </td>
<td align="center"> <s:property value="#usercomment.subject" /> </td>
<td align="center"> <s:property value="#usercomment.comments" /> </td>
<s:if test="%{deploymentVersion !='All'}">
<td align="center"> <s:date name="#usercomment.closingDate" format="MM/dd/yyyy" /> </td>
</s:if>
</tr>
</s:iterator>
The <s:iterator> tag is showing properties values(projectNm, subject,comments)correctly. 'deploymentVersion' property is not a member of 'usercomment' and when it is having value 'All' still it is displaying '#usercomment.closingDate' value. I think that it is not validating <s:if> condition correctly inside <s:iterator>. If I move this condition outside of <s:iterator> it is working as expected.
Please let me know, how to validate the properties which are not member of <s:iterator> value.
Thanks,Sharath.

Attachment:
user_188101.ezm (zipped)> <s:if test="%{deploymentVersion !='All'}">
Maybe use <s:if/> tag instead?
http://struts.apache.org/2.1.2/docs/if.html
Regards
--
Lukasz
http://www.lenart.org.pl/

Attachment:
user_188102.ezm (zipped)Hi Sarath,
where from this deploymentVersion is from (action, session)?
Such construction works for me in many places, so i would like to
replicate this problem.
Best greetings,
Paweł Wielgus.
2008/6/25 sharath karnati <karnatis@(protected)>:
> Hi All,
>
> In .jsp file, I'm having following code which is using <s:iterator> tag.
>
> <s:iterator value="userCommentsList" id="usercomment">
> <tr>
> <td align="center"> <s:property value="#usercomment.projectNm" /> </td>
> <td align="center"> <s:property value="#usercomment.subject" /> </td>
> <td align="center"> <s:property value="#usercomment.comments" /> </td>
>
> <s:if test="%{deploymentVersion !='All'}">
> <td align="center"> <s:date name="#usercomment.closingDate" format="MM/dd/yyyy" /> </td>
> </s:if>
> </tr>
> </s:iterator>
>
> The <s:iterator> tag is showing properties values(projectNm, subject,comments)correctly. 'deploymentVersion' property is not a member of 'usercomment' and when it is having value 'All' still it is displaying '#usercomment.closingDate' value. I think that it is not validating <s:if> condition correctly inside <s:iterator>. If I move this condition outside of <s:iterator> it is working as expected.
>
> Please let me know, how to validate the properties which are not member of <s:iterator> value.
>
> Thanks,Sharath.
>
>
>
>

Attachment:
user_188104.ezm (zipped)The deploymentVersion is from 'action'. I even tried with <c:if> and it is also having same issue.
Thanks,
Sharath.
--- On Wed, 6/25/08, Paweł Wielgus <poulwiel@(protected):
From: Paweł Wielgus <poulwiel@(protected)>
Subject: Re: weird problem <s:iterator> tag.
To: "Struts Users Mailing List" <user@(protected)
Date: Wednesday, June 25, 2008, 5:38 PM
Hi Sarath,
where from this deploymentVersion is from (action, session)?
Such construction works for me in many places, so i would like to
replicate this problem.
Best greetings,
Paweł Wielgus.
2008/6/25 sharath karnati <karnatis@(protected)>:
> Hi All,
>
> In .jsp file, I'm having following code which is using
<s:iterator> tag.
>
> <s:iterator value="userCommentsList"
id="usercomment">
> <tr>
> <td align="center"> <s:property
value="#usercomment.projectNm" /> </td>
> <td align="center"> <s:property
value="#usercomment.subject" /> </td>
> <td align="center"> <s:property
value="#usercomment.comments" /> </td>
>
> <s:if test="%{deploymentVersion !='All'}">
> <td align="center"> <s:date
name="#usercomment.closingDate" format="MM/dd/yyyy" />
</td>
> </s:if>
> </tr>
> </s:iterator>
>
> The <s:iterator> tag is showing properties values(projectNm,
subject,comments)correctly. 'deploymentVersion' property is not a
member of 'usercomment' and when it is having value 'All'
still it is displaying '#usercomment.closingDate' value. I think that
it is not validating <s:if> condition correctly inside
<s:iterator>. If I move this condition outside of <s:iterator> it
is working as expected.
>
> Please let me know, how to validate the properties which are not member
of <s:iterator> value.
>
> Thanks,Sharath.
>
>
>
>

Attachment:
user_188105.ezm (zipped)I'm able to fix this problem using 'top'
Thanks,
Sharath.
--- On Wed, 6/25/08, sharath karnati <karnatis@(protected):
From: sharath karnati <karnatis@(protected)>
Subject: Re: weird problem <s:iterator> tag.
To: "Paweł Wielgus" <poulwiel@(protected)
Date: Wednesday, June 25, 2008, 6:05 PM
The deploymentVersion is from 'action'. I even tried with <c:if>
and it is also having same issue.
Thanks,
Sharath.
--- On Wed, 6/25/08, Paweł Wielgus <poulwiel@(protected):
From: Paweł Wielgus <poulwiel@(protected)>
Subject: Re: weird problem <s:iterator> tag.
To: "Struts Users Mailing List" <user@(protected)>,
karnatis@(protected)
Date: Wednesday, June 25, 2008, 5:38 PM
Hi Sarath,
where from this deploymentVersion is from (action, session)?
Such construction works for me in many places, so i would like to
replicate this problem.
Best greetings,
Paweł Wielgus.
2008/6/25 sharath karnati <karnatis@(protected)>:
> Hi All,
>
> In .jsp file, I'm having following code which is using
<s:iterator> tag.
>
> <s:iterator value="userCommentsList"
id="usercomment">
> <tr>
> <td align="center"> <s:property
value="#usercomment.projectNm" /> </td>
> <td align="center"> <s:property
value="#usercomment.subject" /> </td>
> <td align="center"> <s:property
value="#usercomment.comments" /> </td>
>
> <s:if test="%{deploymentVersion !='All'}">
> <td align="center"> <s:date
name="#usercomment.closingDate" format="MM/dd/yyyy" />
</td>
> </s:if>
> </tr>
> </s:iterator>
>
> The <s:iterator> tag is showing properties values(projectNm,
subject,comments)correctly. 'deploymentVersion' property is not a
member of 'usercomment' and when it is having value 'All'
still it is displaying '#usercomment.closingDate' value. I think that
it is not validating <s:if> condition correctly inside
<s:iterator>. If I move this condition outside of <s:iterator> it
is working as expected.
>
> Please let me know, how to validate the properties which are not member
of <s:iterator> value.
>
> Thanks,Sharath.
>
>
>
>

Attachment:
user_188103.ezm (zipped)
Now, server-side validation works!
I changed ActionErrors class with ActionMessages class into my java
validation method and into "validator-rules.xml".
The only problem is that
Resources.getActionMessage(request, va, field)
method in my custom validator class is deprecated and I don't know how to
replace it.
Can you give me any suggestions?
On the client-side, I have the same problem.
I see a javascript warning in browser: "twofields is not defined".
I have also tried to perform some changes to my files:
**************
validator-rules.xml
**************
<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD
Commons Validator Rules Configuration 1.3.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
...
...
...
<validator name="twofields"
classname="it.sfidiamoci.validator.ValidatorPersonalizzati"
method="validateTwoFields"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
javax.servlet.http.HttpServletRequest"
depends="required"
msg="errors.twofields">
<javascript><![CDATA[
function validateTwoFields(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oTwoFields = new twofields();
for (x in oTwoFields) {
var field = form[oTwoFields[x][0]];
var secondField = form[oTwoFields[x][2]("secondProperty")];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'select-one' ||
field.type == 'radio' ||
field.type == 'password') {
var value;
var secondValue;
// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;
value = field.options[si].value;
secondValue = secondField.options[si].value;
} else {
value = field.value;
secondValue = secondField.value;
}
if (value != secondValue) {
if (i == 0) {
focusField = field;
}
fields[i++] = oTwoFields[x][1];
bValid = false;
}
}
}
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
}
return bValid;
}]]></javascript>
</validator>
**********
validation.xml
**********
<!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">
...
...
...
<field property="password" depends="required,minlength,mask,twofields">
<arg position="0" key="errors.password" />
<arg position="1" name="minlength" key="${var:minlength}"
resource="false" />
<msg name="mask" key="errors.mask.password" />
<msg name="uguale" key="errors.password.uguale" />
<var>
<var-name>minlength</var-name>
<var-value>8</var-value>
</var>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z0-9_.]*$</var-value>
</var>
<var>
<var-name>secondProperty</var-name>
<var-value>password2</var-value>
</var>
</field>
So, my custom validation ("twofields") doesn't still work on client-side.
Can you help me?
I also tried to change the version of dtd validator...but nothing changed.
I can't understand where is the problem.
cacodemon79 wrote:
>
> I'm using Struts 1.3.
> I'm trying to write a custom validator to check that 2 fields are
> identical.
>
> 1) I modified my validator-rules.xml by adding my own validator (called
> "uguale"):
> **************
> validator-rules.xml
> **************
> <validator name="uguale"
> classname="it.sfidiamoci.validator.ValidatorPersonalizzati"
> method="validateUguale"
>
> methodParams="java.lang.Object,org.apache.commons.validator.ValidatorAction,org.apache.commons.validator.Field,org.apache.struts.action.ActionErrors,javax.servlet.http.HttpServletRequest"
> depends="required"
> msg="errors.uguale">
>
> <javascript><![CDATA[
> function validateUguale(form) {
> var bValid = true;
> var focusField = null;
> var i = 0;
> var fields = new Array();
> oTwoFields = new twofields();
> for (x in oTwoFields) {
> var field = form[oTwoFields[x][0]];
> var secondField =
> form[oTwoFields[x][2]("secondProperty")];
>
> if (field.type == 'text' ||
> field.type == 'textarea' ||
> field.type == 'select-one' ||
> field.type == 'radio' ||
> field.type == 'password') {
>
> var value;
> var secondValue;
> // get field's value
> if (field.type == "select-one") {
> var si = field.selectedIndex;
> value = field.options[si].value;
> secondValue = secondField.options[si].value;
> } else {
> value = field.value;
> secondValue = secondField.value;
> }
>
> if (value != secondValue) {
>
> if (i == 0) {
> focusField = field;
> }
> fields[i++] = oTwoFields[x][1];
> bValid = false;
> }
> }
> }
>
> if (fields.length > 0) {
> focusField.focus();
> alert(fields.join('\n'));
> }
>
> return bValid;
> }]]></javascript>
>
> </validator>
>
> 2) I modified my validation.xml by adding the new validator (called
> "uguale"):
> **************
> validator-rules.xml
> **************
> <i<field property="password" depends="required,minlength,mask,uguale">
> <arg position="0" key="errors.password" />
> <arg position="1" name="minlength" key="${var:minlength}"
> resource="false" />
> <msg name="mask" key="errors.mask.password" />
> <msg name="uguale" key="errors.password.uguale" />
> <var>
> <var-name>minlength</var-name>
> <var-value>8</var-value>
> </var>
> <var>
> <var-name>mask</var-name>
> <var-value>^[a-zA-Z0-9_.]*$</var-value>
> </var>
> <var>
> <var-name>secondProperty</var-name>
> <var-value>password2</var-value>
> </var>
> </field>
>
> 3) I added the key "errors.password.uguale" in
> ApplicationResources.properties
> ***********************
> ApplicationResources.properties
> ***********************
> errors.password.uguale=Le password inserite non sono uguali
>
> 4) I created the class "ValidatorPersonalizzati" to handle the custom
> validator "validateUguale":
> ********************
> ValidatorPersonalizzati.java
> ********************
> package it.sfidiamoci.validator;
>
> import javax.servlet.http.HttpServletRequest;
>
> import org.apache.commons.validator.Field;
> import org.apache.commons.validator.GenericValidator;
> import org.apache.commons.validator.ValidatorAction;
> import org.apache.commons.validator.util.ValidatorUtils;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.validator.Resources;
>
>
> public class ValidatorPersonalizzati{
>
> public static boolean validateUguale(Object bean, ValidatorAction
> va,Field field, ActionErrors errors,HttpServletRequest request){
>
> String value =
> ValidatorUtils.getValueAsString(bean,field.getProperty());
> System.out.println("value="+value);
> String sProperty2 = field.getVarValue("secondProperty");
> String value2 = ValidatorUtils.getValueAsString(bean,sProperty2);
> System.out.println("value2="+value2);
> if (!GenericValidator.isBlankOrNull(value)){
> try{
> if (!value.equals(value2)){
> errors.add(field.getKey(),Resources.getActionMessage(request, va,
> field));
> return false;
> }
> }
> catch (Exception e){
> errors.add(field.getKey(),Resources.getActionMessage(request, va,
> field));
> return false;
> }
> }
>
> return true;
>
> }
> }
>
> 5) I have two fields ("password", "password2") to check in my jsp:
> ******
> test.jsp
> ******
> <tr>
> <td class="col1"><bean:message
> key='registrazioneUtente.password.label'/></td>
> <td><html:password property="password" styleId="password"
> maxlength="<%= passwordMaxLength %>" /></td>
> <td><bean:message key='registrazioneUtente.password2.label'/></td>
> <td><html:password property="password2" styleId="password2"
> maxlength="<%= passwordMaxLength %>" /></td>
> </tr>
>
>
> When I submit the form in my jsp, standard validations (e.g. required,
> minlength, ...) of other fields are performed in the correct way.
> Instead, my own validation called "uguale" ("password==password2") doesn't
> work!
> On the client-side, I see a javascript warning in browser: "twofields is
> not defined" but no javascript alert.
> On the server-side, I get the following exception:
>
> value=cvcxvxvczczx
> value2=czzxcczxczczczcz
> 24-giu-2008 20.54.30 org.apache.commons.validator.ValidatorAction
> executeValidationMethod
> GRAVE: Unhandled exception thrown during validation: null
> java.lang.NullPointerException
> at
> it.sfidiamoci.validator.ValidatorPersonalizzati.validateUguale(ValidatorPersonalizzati.java:30)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:544)
> at org.apache.commons.validator.Field.validateForRule(Field.java:796)
> at org.apache.commons.validator.Field.validate(Field.java:876)
> at org.apache.commons.validator.Form.validate(Form.java:288)
> at org.apache.commons.validator.Validator.validate(Validator.java:351)
> at
> org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:116)
> at
> org.apache.struts.chain.commands.servlet.ValidateActionForm.validate(ValidateActionForm.java:58)
> at
> org.apache.struts.chain.commands.AbstractValidateActionForm.execute(AbstractValidateActionForm.java:120)
> at
> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
> at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
> at
> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
> at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
> at
> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
> at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
> at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Unknown Source)
>
> In the log I have left 2 System.out.println to be sure that "value" and
> "value2" variables had the correct value submitted through the form.
>
> Moreover, I'm not sure that
> Resources.getActionMessage(request, va, field)
> method in my custom validator class is correct. This method is deprecated
> and I don't know how to replace it.
>
> I can't understand where is the problem both on client-side and on
> server-side validation.
>
> Can you help me?
>
> Thanks in advance.
>
--
Sent from the Struts - User mailing list archive at Nabble.com.