Re: Dispatch does not work ( Struts2 + tile)
On Wed, Dec 23, 2009 at 12:27 PM, Emi Lu em...@encs.concordia.ca wrote: (1) jsp s:form namespace=/Edit action=ProcessTest [snip] action name=editProcessTest class=ProcessTest method=edit That form doesn't look like it is calling the action... Your action is named 'editProcessTest', but the form points to 'ProcessTest'. Are there more pieces (spring configuration, etc.) that we need to see? -Wes -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: best practices in struts 2.1 - Tiles and Convention - clean URLs with minimum number of actions
Charles, I haven't really found any way to get around the setup you are talking about... If you want validation, you pretty much have to map to different actionable URLs. From the framework's perspective, it really can't know that you want validation or not without different request URLs. The alternative is to try to code around it, but then your UI logic becomes entangled into your application code. -Wes On Tue, Dec 22, 2009 at 11:05 AM, Charles Parker chuck.t.par...@namesforlife.com wrote: I'm using struts 2.1.8.1 here and have a question about best practices in the following situation: I have a form page, 'register'. It takes several fields, username, password, etc. I want the initial form page to be rendered via GET: http://my.server.net/register This shows the blank form (the tile definition below), without attempting to validate the fields. definition name=registrationPage extends=defaultLayout put-attribute name=content value=/WEB-INF/pages/registration.jsp/ /definition On POST to the same URL 'http://my.server.net/register', I want to perform validation on the form, (via register-validation.xml or Annotation). If the form validates then perform the action that triggers the underlying business logic. Otherwise re-display the form with validation errors (again, same URL, 'http://my.server.net/register'). I am using the Convention plugin and the Tiles plugin. The combination of these two seems to throw a wrench in the works. It seems that with the Convention plugin, I can only depend on execute() being called, or I need to define multiple actions. The approach I'm using now works reasonably well but there must be a cleaner way: @ParentPackage(testing) public class Register extends ActionSupport { �...@action(value=register,result...@result(name=input, type=tiles, location=registrationPage)}) �...@skipvalidation public String execute() throws Exception { return this.isBlank() ? INPUT : submit; } �...@action ( value=register-submit, results= { �...@result(name=input, type=tiles, location=registrationPage), �...@result(name=error, type=tiles, location=registrationPage), �...@result(name=success, type=tiles, location=registrationSuccessfulPage) } ) public String executeValidate() throws Exception { // perform business logic return SUCCESS; } private boolean isBlank() { return StringUtils.isBlank(this.username) StringUtils.isBlank(this.password) } } Someone can still link in to /register-submit, which isn't awful, since validation is performed. But I'd like to minimize the number of actionable URLs on my site and avoid writing an isBlank() method for each form. It would seem more straightforward if I could depend on an INPUT result on the first load of the page (with @SkipValidation), and then execute() thereafter, with only a single action defined at the class level instead of multiple actions at the method level. Is this possible, and if so, what is the most appropriate way to do this via struts 2.1? I am addicted to the Convention plugin annotation, and I cannot do without Tiles. For reference, I'm using the following in struts.xml: constant name=struts.convention.action.alwaysMapExecute value=false/ package name=testing extends=struts-default !-- Set the tiles result type as the default for this package. -- result-types result-type name=tiles class=org.apache.struts2.views.tiles.TilesResult default=true/ /result-types /package Many thanks for any alternatives or refinements of this approach. / chuck - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Forwarding to a Java Application
In a Web Application I need to redirect the flow of the information to a Java class nor to a Servlet or a JSP. However in the web i have found a lot of material but none mentions what i am looking for. How is this achieved? Any idea is welcome. Rafael _ Keep your friends updated—even when you’re not signed in. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010
Re: Forwarding to a Java Application
Will the Java App(let) be up and running, or will you need to launch it with the information passed to it? -Wes On Thu, Dec 24, 2009 at 10:52 AM, Rafael Muneton rafael_mune...@hotmail.com wrote: In a Web Application I need to redirect the flow of the information to a Java class nor to a Servlet or a JSP. However in the web i have found a lot of material but none mentions what i am looking for. How is this achieved? Any idea is welcome. Rafael _ Keep your friends updated—even when you’re not signed in. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010 -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Forwarding to a Java Application
On Thursday 24 December 2009 16:52:35 Rafael Muneton wrote: In a Web Application I need to redirect the flow of the information to a Java class nor to a Servlet or a JSP. However in the web i have found a lot of material but none mentions what i am looking for. How is this achieved? When information are sent to the web server, they are always directed towards a Servlet, but it can be intercepted by a Filter or Listener. Even with JSP, we're talking about a Servlet that was created automatically by the container from the JSP page. AFAIK, these are the only classes that can interact *directly* with the web application. Then come the frameworks, which deliver a set of classes (again, Servlets, Filters, Listeners...) that abstract all the complexity for us and we can develop simpler classes that interact with the WebApp. But in reality, they are interacting with the classes the framework provides. With Struts2, you can create Actions, register them with the framework and they can receive the data directly from the web pages. Struts2 will automatically convert and inject them in the action's properties, given the rules have been followed correctly. I don't know if I understood your question right, so I don't know if I answered it well. Ciao, Vítor Souza - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Forwarding to a Java Application
Hi Wes: Well, this web application is the entry to a whole application, it is the MainMenu screen where I have several menu options the user can choose from.And depending on the User , I allow some options or allow all the options. Rafael Date: Thu, 24 Dec 2009 11:37:42 -0500 Subject: Re: Forwarding to a Java Application From: w...@wantii.com To: user@struts.apache.org Will the Java App(let) be up and running, or will you need to launch it with the information passed to it? -Wes On Thu, Dec 24, 2009 at 10:52 AM, Rafael Muneton rafael_mune...@hotmail.com wrote: In a Web Application I need to redirect the flow of the information to a Java class nor to a Servlet or a JSP. However in the web i have found a lot of material but none mentions what i am looking for. How is this achieved? Any idea is welcome. Rafael _ Keep your friends updated—even when you’re not signed in. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010 -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows Live: Keep your friends up to date with what you do online. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010
RE: Forwarding to a Java Application
Hi Vitor: What I am trying to achieve is that , after a user can log in to the Web Application, this user receives the MainMenu screen of the Application, where there are several options, that he/she can choose from.This MainMenu is a Java application not a Servlet. And after reading your answer, I think that maybe I need to upgrade to Struts 2. I am using Struts 1.1 Thanks. Rafael From: vitorso...@gmail.com To: user@struts.apache.org Subject: Re: Forwarding to a Java Application Date: Thu, 24 Dec 2009 18:38:33 +0100 On Thursday 24 December 2009 16:52:35 Rafael Muneton wrote: In a Web Application I need to redirect the flow of the information to a Java class nor to a Servlet or a JSP. However in the web i have found a lot of material but none mentions what i am looking for. How is this achieved? When information are sent to the web server, they are always directed towards a Servlet, but it can be intercepted by a Filter or Listener. Even with JSP, we're talking about a Servlet that was created automatically by the container from the JSP page. AFAIK, these are the only classes that can interact *directly* with the web application. Then come the frameworks, which deliver a set of classes (again, Servlets, Filters, Listeners...) that abstract all the complexity for us and we can develop simpler classes that interact with the WebApp. But in reality, they are interacting with the classes the framework provides. With Struts2, you can create Actions, register them with the framework and they can receive the data directly from the web pages. Struts2 will automatically convert and inject them in the action's properties, given the rules have been followed correctly. I don't know if I understood your question right, so I don't know if I answered it well. Ciao, Vítor Souza - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows Live: Make it easier for your friends to see what you’re up to on Facebook. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
Re: Forwarding to a Java Application
On Thu, Dec 24, 2009 at 12:52 PM, Rafael Muneton rafael_mune...@hotmail.com wrote: Hi Vitor: What I am trying to achieve is that , after a user can log in to the Web Application, this user receives the MainMenu screen of the Application, where there are several options, that he/she can choose from.This MainMenu is a Java application not a Servlet. And after reading your answer, I think that maybe I need to upgrade to Struts 2. I am using Struts 1.1 I don't think an upgrade is necessary. I think you just need to understand a little better how things work in a JSP/Servlet environment... The page that launches the MainMenu application is bound to have either an applet... or object... tag. It has been a while for me, I can't remember which. But, if there is information that needs passed to the MainMenu, then you need to make that information into params. Then, when the page that launches the MainMenu is rendered, pass the information to the MainMenu by rendering the appropriate param... tags. -Wes -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Forwarding to a Java Application
OK Wes: I am trying to understand you. I will test my Appl and will keep you posted. Thanks a lot. Rafael Date: Thu, 24 Dec 2009 13:48:49 -0500 Subject: Re: Forwarding to a Java Application From: w...@wantii.com To: user@struts.apache.org On Thu, Dec 24, 2009 at 12:52 PM, Rafael Muneton rafael_mune...@hotmail.com wrote: Hi Vitor: What I am trying to achieve is that , after a user can log in to the Web Application, this user receives the MainMenu screen of the Application, where there are several options, that he/she can choose from.This MainMenu is a Java application not a Servlet. And after reading your answer, I think that maybe I need to upgrade to Struts 2. I am using Struts 1.1 I don't think an upgrade is necessary. I think you just need to understand a little better how things work in a JSP/Servlet environment... The page that launches the MainMenu application is bound to have either an applet... or object... tag. It has been a while for me, I can't remember which. But, if there is information that needs passed to the MainMenu, then you need to make that information into params. Then, when the page that launches the MainMenu is rendered, pass the information to the MainMenu by rendering the appropriate param... tags. -Wes -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010
how to access struts2 propery from jsp or vice versa
Hello, I am stuck in trying to access some variables from value stack in jsp page. Is there anyway to do it easily? Is there anyway to communicate with a bean defined in jsp with jsp:useBean tag from struts2? I can access values in struts but not from jsp side. ..Basically I am trying to do something similar to % response.sendRedirect(..url based ons:property value=%{GRTGRTGT}/ .); Please, tell me if and how can I accomplish something like this. Regards, Parminder Lehal -Original Message- From: Wes Wannemacher w...@wantii.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: Re: if tag with #parameters Date: Wed, 23 Dec 2009 09:35:59 -0500 I have used a similar construct quite a bit, but normally, I refer to parameters like this - s:if test=%{#parameters['view'] != null} view /s:if s:else not view /s:else In cases like this, I just want to affect the way a view is rendered. So, leaving the getter/setter off of the action is the way to go. -Wes On Tue, Dec 22, 2009 at 6:05 AM, foo bar linut...@gmail.com wrote: Hi, I would prefer not to use getter/setter. What I really want to know is, why is this not working as expected ? Anyway, I solved it s:if test=#parameters.messageKey[0] == 'yes' #parameters.messageKey is of type String[], which make sense now On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal saee...@gmail.com wrote: If it is a request parameter, then make a setter for it to get set and getter to retrieve it and use % instead of # If you want to have the parameter in the page context use the s:set with id On Tue, Dec 22, 2009 at 3:36 PM, foo bar linut...@gmail.com wrote: Hi all, I'm testing for the existence of a request parameter in a jsp page in Struts 2 %@ taglib prefix=s uri=/struts-tags% !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; s:property value=#parameters.messageKey/br/ s:if test=%{#parameters.messageKey == 'yes'} yes /s:if s:else no /s:else But, whatever I do, result is always no Tested with these cases: test.jsp test.jsp?messageKey= test.jsp?messageKey=yes test.jsp?messageKey=no Changed it to s:if test=#parameters.messageKey == 'yes', same results Changed it to s:if test={#parameters.messageKey == 'yes'}, results are negated as above, ie you got no when previously you got yes What's the solution here ? Cheers - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Saeed Iqbal Independant Consultant J2EE - Application Architect / Developer - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: how to access struts2 propery from jsp or vice versa
There is an http header result type and two redirect result types that are much better suited for this. You can use properties in the struts.xml file as params for the result. I am on my phone, but perhaps someone else can post an example. -W On 12/24/09, Parm Lehal ple...@lehal.net wrote: Hello, I am stuck in trying to access some variables from value stack in jsp page. Is there anyway to do it easily? Is there anyway to communicate with a bean defined in jsp with jsp:useBean tag from struts2? I can access values in struts but not from jsp side. ..Basically I am trying to do something similar to % response.sendRedirect(..url based ons:property value=%{GRTGRTGT}/ .); Please, tell me if and how can I accomplish something like this. Regards, Parminder Lehal -Original Message- From: Wes Wannemacher w...@wantii.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: Re: if tag with #parameters Date: Wed, 23 Dec 2009 09:35:59 -0500 I have used a similar construct quite a bit, but normally, I refer to parameters like this - s:if test=%{#parameters['view'] != null} view /s:if s:else not view /s:else In cases like this, I just want to affect the way a view is rendered. So, leaving the getter/setter off of the action is the way to go. -Wes On Tue, Dec 22, 2009 at 6:05 AM, foo bar linut...@gmail.com wrote: Hi, I would prefer not to use getter/setter. What I really want to know is, why is this not working as expected ? Anyway, I solved it s:if test=#parameters.messageKey[0] == 'yes' #parameters.messageKey is of type String[], which make sense now On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal saee...@gmail.com wrote: If it is a request parameter, then make a setter for it to get set and getter to retrieve it and use % instead of # If you want to have the parameter in the page context use the s:set with id On Tue, Dec 22, 2009 at 3:36 PM, foo bar linut...@gmail.com wrote: Hi all, I'm testing for the existence of a request parameter in a jsp page in Struts 2 %@ taglib prefix=s uri=/struts-tags% !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; s:property value=#parameters.messageKey/br/ s:if test=%{#parameters.messageKey == 'yes'} yes /s:if s:else no /s:else But, whatever I do, result is always no Tested with these cases: test.jsp test.jsp?messageKey= test.jsp?messageKey=yes test.jsp?messageKey=no Changed it to s:if test=#parameters.messageKey == 'yes', same results Changed it to s:if test={#parameters.messageKey == 'yes'}, results are negated as above, ie you got no when previously you got yes What's the solution here ? Cheers - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Saeed Iqbal Independant Consultant J2EE - Application Architect / Developer - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org