Discussion:
Does validator work with Lookup dispatch action
mosho
2006-07-12 14:15:46 UTC
Permalink
Hi,

I am using struts for my application. I have 3 buttons in my form i.e
prev,next,clear.
I read few articles and found that Lookup dispatch action will be the best
option to use.

I have few concerns using lookupdispatch action,
1. Will I be able to validate using struts validator?
2. I need to validate only when next button is hit, is that possible?

Is there any tutorial avialable for using lookup dispatch action.

Thanks
Mosho
--
View this message in context: http://www.nabble.com/Does-validator-work-with-Lookup-dispatch-action-tf1931125.html#a5289472
Sent from the Struts - User forum at Nabble.com.
David Durham
2006-07-12 14:20:09 UTC
Permalink
Post by mosho
I have few concerns using lookupdispatch action,
1. Will I be able to validate using struts validator?
2. I need to validate only when next button is hit, is that possible?
Is there any tutorial avialable for using lookup dispatch action.
I've done something similar by explicitly calling form.validate() from
within the "execute" method, but this has a bad smell. Someone else
probably has a better approach.


-Dave
Samere, Adam J
2006-07-12 14:24:02 UTC
Permalink
You can set the page attribute on your form validation definition, then
use client side script to set the page request parameter based on which
button is clicked.

You might want to look at MappingDispatchAction as well.

-----Original Message-----
From: David Durham [mailto:***@vailsys.com]
Sent: Wednesday, July 12, 2006 10:20 AM
To: Struts Users Mailing List
Subject: Re: Does validator work with Lookup dispatch action
I have few concerns using lookupdispatch action, 1. Will I be able to
validate using struts validator?
2. I need to validate only when next button is hit, is that possible?
Is there any tutorial avialable for using lookup dispatch action.
I've done something similar by explicitly calling form.validate() from
within the "execute" method, but this has a bad smell. Someone else
probably has a better approach.


-Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-mail: user-***@struts.apache.org


-----------------------------------------
The information contained in this message may be privileged,
confidential, and protected from disclosure. If the reader of this
message is not the intended recipient, or any employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution, or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.

Thank you. Paychex, Inc.
mosho
2006-07-12 14:53:28 UTC
Permalink
Thanks for all the replies.

Wendy, I am using struts 1.1 so I don't think I can use EventDispatchAction.

Adam,

what is the difference between MappingDispatchAction and
LookupDispatchAction. Any advantages over LookupDispatchAction?

Also, do you have an example of how to set page attribute and use client
side script to set the page request parameter.

I am new to this, all your help is appreciated.

Mosho
--
View this message in context: http://www.nabble.com/Does-validator-work-with-Lookup-dispatch-action-tf1931125.html#a5290199
Sent from the Struts - User forum at Nabble.com.
mosho
2006-07-12 15:10:01 UTC
Permalink
I have another question, I was just trying to use LookupDispatchAction. It
looks like if I am extending LookupDispatchAction, I don't have to use
excute method. Is that right? I can do all the processing in the respective
previous and next methods.

Previous methods looks like ..for ex:

public ActionForward previous(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// do add
return mapping.findForward("previous");
}

Wendy,you are right my application is a wizard.
--
View this message in context: http://www.nabble.com/Does-validator-work-with-Lookup-dispatch-action-tf1931125.html#a5290575
Sent from the Struts - User forum at Nabble.com.
Juergen Kopper
2006-07-12 15:21:25 UTC
Permalink
Hi,
Post by mosho
I have another question, I was just trying to use LookupDispatchAction. It
looks like if I am extending LookupDispatchAction, I don't have to use
excute method. Is that right?
That's right.
Post by mosho
I can do all the processing in the respective
previous and next methods.
public ActionForward previous(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// do add
return mapping.findForward("previous");
}
Wendy,you are right my application is a wizard.
You also need to override the
protected Map getKeyMethodMap(){
}
to map the buttons to the dispatch methods.

Hope that helps
Juergen
Wendy Smoak
2006-07-12 14:38:31 UTC
Permalink
Post by mosho
I am using struts for my application. I have 3 buttons in my form i.e
prev,next,clear.
I read few articles and found that Lookup dispatch action will be the best
option to use.
There's a *much* better option in EventDispatchAction. It's available
in Struts 1.2.9
http://struts.apache.org/1.2.9/api/org/apache/struts/actions/EventDispatchAction.html
Post by mosho
I have few concerns using lookupdispatch action,
1. Will I be able to validate using struts validator?
2. I need to validate only when next button is hit, is that possible?
Yes, Validator works fine with dispatch actions. For 2, take a look
at this tutorial on calling validation manually:
http://www.learntechnology.net/validate-manually.do

It sounds like you have a wizard-type form, so you can make use of the
<field> 'page' attribute in validation.xml to validate the fields on
all pages up to the current one.
--
Wendy
mosho
2006-07-12 16:15:02 UTC
Permalink
Hi Wendy,

As per my requirement, I need to validate only when next button is hit. I
can validate manually for server-side validation, it is working. How do I
control for clients-side validation?
If I include javascript tag in my jsp, it is going to validate even if I hit
previous or next button.

Thanks for your help
--
View this message in context: http://www.nabble.com/Does-validator-work-with-Lookup-dispatch-action-tf1931125.html#a5291882
Sent from the Struts - User forum at Nabble.com.
mosho
2006-07-13 19:21:23 UTC
Permalink
I have two submit buttons previous and next.
I need to validate only when I hit next button. I can control this by using
page attribute in valdation.xml.
This works for server-side. It doesn't work for client side validation.
How can I do client side validation only when i hit next button.
Is there any solution for it?

Thanks for your help.
--
View this message in context: http://www.nabble.com/Does-validator-work-with-Lookup-dispatch-action-tf1931125.html#a5314885
Sent from the Struts - User forum at Nabble.com.
Loading...