You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rodney Paul <ro...@natdata.net> on 2004/06/28 05:53:54 UTC

LookupDispatchAction Error When Pressing Enter Key

Hi All,

I have a problem in regards to the LookupDispatchAction Struts class.

My problem is in regards to a user pressing the "Enter" key on a keyboard.
In this scenario, a form submit has been activated via html, with no submit buttons having been pressed.
When Struts see's this, the Struts engine displays a java error indicating that the parameter being used for lookup's doesnt exist in the request.

Now is there a way of indicating to Struts that if the user presses the "Enter" key a default action will occur.
In other words, without using Javascript for trapping the "Enter" key, is there a way to tell struts to execute a default method
if the user presses the "Enter" key. In particular a descriptor value indicating the default method to execute.

If possible could anyone help me with a solution to this problem.


Cheers
Rodney Paul


ps. Could Ted Husted please have a look at this.

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


Re: using set-property in forward tag

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Then just add it on to the ActionForward returned from the Action ...

You can use the following method to do this:

protected ActionForward appendParam( String name,
                                      String value,
                               ActionForward forward) {

     StringBuffer path = new StringBuffer(forward.getPath());
     boolean isQuery = (path.indexOf("?") >= 0);
     if (isQuery)
       path.append("&amp;");
     else
       path.append('?');
     path.append(name);
     path.append('=');
     path.append(value);

     return new ActionForward(path.toString(), forward.getRedirect());
}

If you place this method in a BaseAction, then you can call this in your 
ActionB's execute method ...

public ActionForward execute(...) {
   // stuff here
   ActionForward forward = mapping.findForward("success");
   forward = appendParam("foo","bar",forward);
   return forward;
}

Does that help?

Bill Siggelkow

nikhil walvekar wrote:

> Hi,
>    But my value will be dynamic in nature.
> 
> Nikhil
> 
> --- Bill Siggelkow <bi...@bellsouth.net> wrote: >
> Hi Nikhil,
> 
>>   It sounds like what you really want to do is set
>>add a request 
>>parameter name-value pair to the query string of the
>>URL.  If so, then 
>>you can add these values directly in the definition
>>of the foward and 
>>still set redirect = "true" ... The example below
>>passes two parameters 
>>to ActionA -- foo=bar, and baz=blob -- note the use
>>of &amp; to avoid 
>>XML confusion.
>>
>><action path="/ActionB"
>>         type="com.foo.MyAction">
>>     <forward name="success"
>>path="/ActionA.do?foo=bar&amp;baz=blob"/>
>></action>
>>
>>The <set-property> element is used to set a property
>>on the 
>>ForwardConfig object. Typically you only need to do
>>this if you are 
>>providing a custom implementation of the
>>ActionForward object.
>>
>>nikhil walvekar wrote:
>>
>>>Hi, all
>>>
>>>forward element is defined as following
>>>
>>><!ELEMENT forward (icon?, display-name?,
>>
>>description?,
>>
>>>set-property*)>
>>>
>>>actualy i want to pass some values to forward but
>>
>>with
>>
>>>redirect true.
>>>
>>>e.g.Action A expects one parameter..
>>>
>>>I want to forward to action A from action B but
>>
>>with
>>
>>>redirect true option. due to redirect=true i can
>>
>>not
>>
>>>set required property from action B in request and
>>
>>try
>>
>>>to read in action A.
>>>
>>>Forward tag can have sub elements one of which is
>>>set-property.
>>>
>>>Please help me, how can i use set-property in
>>
>>forward
>>
>>>tag.
>>>
>>>Nikhil.
>>>
>>>
>>>
>>
> ________________________________________________________________________
> 
>>>Yahoo! India Matrimony: Find your partner online.
>>
>>http://yahoo.shaadi.com/india-matrimony/
>>
>>
>>
> 
> ---------------------------------------------------------------------
> 
>>To unsubscribe, e-mail:
>>user-unsubscribe@struts.apache.org
>>For additional commands, e-mail:
>>user-help@struts.apache.org
>> 
> 
> 
> =====
>  
> Nikhil  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ________________________________________________________________________
> Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/


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


Re: using set-property in forward tag

Posted by nikhil walvekar <wa...@yahoo.co.in>.
Hi,
   But my value will be dynamic in nature.

Nikhil

--- Bill Siggelkow <bi...@bellsouth.net> wrote: >
Hi Nikhil,
>    It sounds like what you really want to do is set
> add a request 
> parameter name-value pair to the query string of the
> URL.  If so, then 
> you can add these values directly in the definition
> of the foward and 
> still set redirect = "true" ... The example below
> passes two parameters 
> to ActionA -- foo=bar, and baz=blob -- note the use
> of &amp; to avoid 
> XML confusion.
> 
> <action path="/ActionB"
>          type="com.foo.MyAction">
>      <forward name="success"
> path="/ActionA.do?foo=bar&amp;baz=blob"/>
> </action>
> 
> The <set-property> element is used to set a property
> on the 
> ForwardConfig object. Typically you only need to do
> this if you are 
> providing a custom implementation of the
> ActionForward object.
> 
> nikhil walvekar wrote:
> > Hi, all
> > 
> > forward element is defined as following
> > 
> > <!ELEMENT forward (icon?, display-name?,
> description?,
> > set-property*)>
> > 
> > actualy i want to pass some values to forward but
> with
> > redirect true.
> > 
> > e.g.Action A expects one parameter..
> > 
> > I want to forward to action A from action B but
> with
> > redirect true option. due to redirect=true i can
> not
> > set required property from action B in request and
> try
> > to read in action A.
> > 
> > Forward tag can have sub elements one of which is
> > set-property.
> > 
> > Please help me, how can i use set-property in
> forward
> > tag.
> > 
> > Nikhil.
> > 
> > 
> >
>
________________________________________________________________________
> > Yahoo! India Matrimony: Find your partner online.
> http://yahoo.shaadi.com/india-matrimony/
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>  

=====
 
Nikhil  













________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/

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


Re: using set-property in forward tag

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Hi Nikhil,
   It sounds like what you really want to do is set add a request 
parameter name-value pair to the query string of the URL.  If so, then 
you can add these values directly in the definition of the foward and 
still set redirect = "true" ... The example below passes two parameters 
to ActionA -- foo=bar, and baz=blob -- note the use of &amp; to avoid 
XML confusion.

<action path="/ActionB"
         type="com.foo.MyAction">
     <forward name="success" path="/ActionA.do?foo=bar&amp;baz=blob"/>
</action>

The <set-property> element is used to set a property on the 
ForwardConfig object. Typically you only need to do this if you are 
providing a custom implementation of the ActionForward object.

nikhil walvekar wrote:
> Hi, all
> 
> forward element is defined as following
> 
> <!ELEMENT forward (icon?, display-name?, description?,
> set-property*)>
> 
> actualy i want to pass some values to forward but with
> redirect true.
> 
> e.g.Action A expects one parameter..
> 
> I want to forward to action A from action B but with
> redirect true option. due to redirect=true i can not
> set required property from action B in request and try
> to read in action A.
> 
> Forward tag can have sub elements one of which is
> set-property.
> 
> Please help me, how can i use set-property in forward
> tag.
> 
> Nikhil.
> 
> 
> ________________________________________________________________________
> Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/


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


using set-property in forward tag

Posted by nikhil walvekar <wa...@yahoo.co.in>.
Hi, all

forward element is defined as following

<!ELEMENT forward (icon?, display-name?, description?,
set-property*)>

actualy i want to pass some values to forward but with
redirect true.

e.g.Action A expects one parameter..

I want to forward to action A from action B but with
redirect true option. due to redirect=true i can not
set required property from action B in request and try
to read in action A.

Forward tag can have sub elements one of which is
set-property.

Please help me, how can i use set-property in forward
tag.

Nikhil.


________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/

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


Re: LookupDispatchAction Error When Pressing Enter Key

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Hmm .. I just tested using a LookupDispatchAction and Firefox 0.9 -- I 
found that when I pressed Enter it submitted using the first submit 
button defined. That being said, you can override the "unspecified" 
method of DispatchAction -- this method will be called instead of a 
ServletException being thrown if an unknown or empty method is received.

Rodney Paul wrote:
> Hi All,
> 
> I have a problem in regards to the LookupDispatchAction Struts class.
> 
> My problem is in regards to a user pressing the "Enter" key on a keyboard.
> In this scenario, a form submit has been activated via html, with no submit buttons having been pressed.
> When Struts see's this, the Struts engine displays a java error indicating that the parameter being used for lookup's doesnt exist in the request.
> 
> Now is there a way of indicating to Struts that if the user presses the "Enter" key a default action will occur.
> In other words, without using Javascript for trapping the "Enter" key, is there a way to tell struts to execute a default method
> if the user presses the "Enter" key. In particular a descriptor value indicating the default method to execute.
> 
> If possible could anyone help me with a solution to this problem.
> 
> 
> Cheers
> Rodney Paul
> 
> 
> ps. Could Ted Husted please have a look at this.


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