Any idea? On Fri, Dec 12, 2008 at 6:04 PM, Faraz Ali <farazali.fa...@gmail.com> wrote:
> Hi Andy, > > Please take a look at the code snippet and suggest. > > *MyAction.java* > public class MyAction extends ActionSupport { > //getAction > //setAction > public String execute() throws Exception { > if(action==1) { > return "input"; > } elseif(action==2) { > return "showResult"; > } else { > return "success"; > } > } > } > > *struts.xml:* > <package name="web" namespace="/web" extends="struts-default"> > <action name="MyAction" class="com.test.web.actions.MyAction"> > <result name="showResult">/jsps/showResult.jsp</result> > <result name="input">/jsps/inputPage.jsp</result> > <result>/jsps/successPage</result> > </action> > </package> > > *index.jsp:* > <s:action name="MyAction" namespace="/web" executeResult="true"> > <s:param name="action">2</s:param> > </s:action> > > In my index.jsp, i am calling action to display showResult.jsp page. But > dont know why it is displaying inputPage.jsp. I also put a breakpoint in my > Action class and start the application in debug mode, but the execute method > did not called. > Please tell me whats happening? If you need more information please tell me > > On Thu, Dec 11, 2008 at 4:04 AM, Andy Sykes <a.sy...@ucl.ac.uk> wrote: > >> Faraz, >> >> I think at this point some code would help. Could you post your >> struts.xml, and the action? >> >> Andy. >> >> On 10 Dec 2008, at 17:16, Faraz Ali wrote: >> >> Yes Andy, you are right. I added the <result name="input">, but why it >>> is >>> executing automatically. It is executed automatically when i start my >>> application. >>> >>> On Wed, Dec 10, 2008 at 6:19 PM, Andy Sykes <a.sy...@ucl.ac.uk> wrote: >>> >>> Faraz, >>>> >>>> When using validation, the input result tells Struts where to >>>> dispatch/redirect to if there's a validation error. When you submit the >>>> form, Struts checks the fields against the validation XML - if there's >>>> an >>>> error, it adds FieldError objects to the FieldErrors object on the value >>>> stack, and dispatches to the JSP (or other resource) defined in the >>>> input >>>> result element. This is nearly always the JSP containing the form you >>>> submitted from. >>>> >>>> You have to have a <result name="input"> because Struts has to know >>>> where >>>> to redirect in the event of a validation error. >>>> >>>> Not sure what you mean by the last bit of your question.. >>>> >>>> Andy. >>>> >>>> >>>> >>>> On 10 Dec 2008, at 05:56, Faraz Ali wrote: >>>> >>>> 13:45:18,390 ERROR [ActionComponent] Could not execute action: >>>> >>>>> /web/MyAction >>>>> No result defined for action com.web.actions.MyAction and result input >>>>> - >>>>> action - file:/C:/ >>>>> jboss-4.2.3.GA/server/default/tmp/deploy/tmp35854MyWeb-exp.war/WEB-<http://jboss-4.2.3.ga/server/default/tmp/deploy/tmp35854MyWeb-exp.war/WEB-> >>>>> < >>>>> http://jboss-4.2.3.ga/server/default/tmp/deploy/tmp35854MyWeb-exp.war/WEB-> >>>>> >>>>> INF/classes/struts.xml:12:69 >>>>> >>>>> 1. I have a simple Action class MyAction >>>>> 2. A corresponding MyAction-validation.xml present in same location as >>>>> Action class >>>>> 3. <s:fielderror /> is included in jsp >>>>> 4. No <result name="input"> is present >>>>> >>>>> My Question is why do we need this input element? Because i want to >>>>> control >>>>> it my way. And if i add this input element, its opening the jsp page at >>>>> the >>>>> start of the application. Can anybody help me how to do validation >>>>> properly >>>>> in struts2 application? >>>>> >>>>> -- >>>>> Best Regards, >>>>> Faraz Ali >>>>> >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>> For additional commands, e-mail: user-h...@struts.apache.org >>>> >>>> >>>> >>> >>> -- >>> Best Regards, >>> Faraz Ali >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > > -- > Best Regards, > Faraz Ali > -- Best Regards, Faraz Ali