You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by robinbajaj <ro...@gmail.com> on 2007/08/02 07:42:09 UTC

[s1] action paths not resolving correctly

Hi All, 
I have done this before with success, don't know where am I missing some bit
this time. 

I have a dispatchAction with the following mapping.
  <action
      input="page.addNewPatient"
      name="navigatePatientForm"
      parameter="do"
      path="/navigatePatient"
      scope="request"
      type="com.bcdrg.struts.action.NavigatePatientAction"
      validate="true">
      <forward name="last" path="page.addNewPatient" />
      <forward name="previous" path="page.addNewPatient" />
      <forward name="first" path="page.addNewPatient" />
      <forward name="next" path="page.addNewPatient" />
    </action>

when I call this dispatch action from a link

navigatePatient.do?do=getFirstPatient 
it works fine, the url requested when i click on this link is 
http://localhost:<port>/<context-path>/navigatePatient.do?do=getFirstPatient

however, when I call the same dispatch action from a regular button, like
shown below:

<input type="button" id="FirstButton" name="First" value="First"					
onclick='setup("getFirstPatient");defaultsetup();document.forms["navigatePatientForm"].submit();'></input>

where setup and defaultsetup are two javascript functions that only setup
some parameters.
But the problem is the url being requested in the browser in this case is :

http://localhost:<port>/navigatePatient?do=getFirstPatient

please note that the <context-path> is missing here, which is why i get the
http 404 error message.

I don't understand why is the <context-path> missing in the second url
request. 

here's my form tag for this form..which seems to be fine too 
<form   name="navigatePatientForm" action="/navigatePatient.do"
onsubmit="return OK();">

any helpful pointers will be much appreciated, 
thanks,
robin
-- 
View this message in context: http://www.nabble.com/-s1--action-paths-not-resolving-correctly-tf4204252.html#a11958775
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s1] action paths not resolving correctly

Posted by robinbajaj <ro...@gmail.com>.
thanks for the advice. I just did that a couple of days ago and got it fixed. 
I noticed it was working from within an <html:form> and was not working from 
within a <form> tag... (which I put in while doing some other ajax stuff).

I replaced the <form.. tag with <html:form .. tag and it started working
fine..
I understand Struts needs <html:form.. tag to handle submit operations etc.
properly..

thanks,
robin

Laurie Harper wrote:
> 
> I can't tell you anything definitive, since you didn't include all your 
> relevant code. I would suggest starting by simplifying things as much as 
> possible. Take out all your Javascript and strip the page down to just a 
> form with a couple of submit buttons dispatching to different methods.
> 
> Once you get that working, start adding functionality back in one piece 
> at a time until you find out what's broken. Fix, and continue.
> 
> L.
> 
> robinbajaj wrote:
>> Hi All, 
>> I have done this before with success, don't know where am I missing some
>> bit
>> this time. 
>> 
>> I have a dispatchAction with the following mapping.
>>   <action
>>       input="page.addNewPatient"
>>       name="navigatePatientForm"
>>       parameter="do"
>>       path="/navigatePatient"
>>       scope="request"
>>       type="com.bcdrg.struts.action.NavigatePatientAction"
>>       validate="true">
>>       <forward name="last" path="page.addNewPatient" />
>>       <forward name="previous" path="page.addNewPatient" />
>>       <forward name="first" path="page.addNewPatient" />
>>       <forward name="next" path="page.addNewPatient" />
>>     </action>
>> 
>> when I call this dispatch action from a link
>> 
>> navigatePatient.do?do=getFirstPatient 
>> it works fine, the url requested when i click on this link is 
>> http://localhost:<port>/<context-path>/navigatePatient.do?do=getFirstPatient
>> 
>> however, when I call the same dispatch action from a regular button, like
>> shown below:
>> 
>> <input type="button" id="FirstButton" name="First" value="First"					
>> onclick='setup("getFirstPatient");defaultsetup();document.forms["navigatePatientForm"].submit();'></input>
>> 
>> where setup and defaultsetup are two javascript functions that only setup
>> some parameters.
>> But the problem is the url being requested in the browser in this case is
>> :
>> 
>> http://localhost:<port>/navigatePatient?do=getFirstPatient
>> 
>> please note that the <context-path> is missing here, which is why i get
>> the
>> http 404 error message.
>> 
>> I don't understand why is the <context-path> missing in the second url
>> request. 
>> 
>> here's my form tag for this form..which seems to be fine too 
>> <form   name="navigatePatientForm" action="/navigatePatient.do"
>> onsubmit="return OK();">
>> 
>> any helpful pointers will be much appreciated, 
>> thanks,
>> robin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s1--action-paths-not-resolving-correctly-tf4204252.html#a11997100
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s1] action paths not resolving correctly

Posted by Laurie Harper <la...@holoweb.net>.
I can't tell you anything definitive, since you didn't include all your 
relevant code. I would suggest starting by simplifying things as much as 
possible. Take out all your Javascript and strip the page down to just a 
form with a couple of submit buttons dispatching to different methods.

Once you get that working, start adding functionality back in one piece 
at a time until you find out what's broken. Fix, and continue.

L.

robinbajaj wrote:
> Hi All, 
> I have done this before with success, don't know where am I missing some bit
> this time. 
> 
> I have a dispatchAction with the following mapping.
>   <action
>       input="page.addNewPatient"
>       name="navigatePatientForm"
>       parameter="do"
>       path="/navigatePatient"
>       scope="request"
>       type="com.bcdrg.struts.action.NavigatePatientAction"
>       validate="true">
>       <forward name="last" path="page.addNewPatient" />
>       <forward name="previous" path="page.addNewPatient" />
>       <forward name="first" path="page.addNewPatient" />
>       <forward name="next" path="page.addNewPatient" />
>     </action>
> 
> when I call this dispatch action from a link
> 
> navigatePatient.do?do=getFirstPatient 
> it works fine, the url requested when i click on this link is 
> http://localhost:<port>/<context-path>/navigatePatient.do?do=getFirstPatient
> 
> however, when I call the same dispatch action from a regular button, like
> shown below:
> 
> <input type="button" id="FirstButton" name="First" value="First"					
> onclick='setup("getFirstPatient");defaultsetup();document.forms["navigatePatientForm"].submit();'></input>
> 
> where setup and defaultsetup are two javascript functions that only setup
> some parameters.
> But the problem is the url being requested in the browser in this case is :
> 
> http://localhost:<port>/navigatePatient?do=getFirstPatient
> 
> please note that the <context-path> is missing here, which is why i get the
> http 404 error message.
> 
> I don't understand why is the <context-path> missing in the second url
> request. 
> 
> here's my form tag for this form..which seems to be fine too 
> <form   name="navigatePatientForm" action="/navigatePatient.do"
> onsubmit="return OK();">
> 
> any helpful pointers will be much appreciated, 
> thanks,
> robin


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