Hi Alex, It seems we have to hard-code JSP path in Java files using Convention plugin. That might make code change a bit difficult later...
Hong -----Original Message----- From: Alex Siman [mailto:aleksandr.si...@gmail.com] Sent: Friday, December 11, 2009 4:20 AM To: user@struts.apache.org Subject: Re: Struts 2 Result + GWT Maybe just use Struts 2 Convention plugin? It will allow you to reuse Java constants in Struts 2 and GWT code. package gwtapp.server.action; import static gwtapp.client.consts.StrutsLocations; @Results({ @Result( name = Action.SUCCESS, location = REGISTRATION_CONFIRMATION ) }) class RegistrationAction {...} package gwtapp.client.consts; class StrutsLocations { public static final String REGISTRATION_CONFIRMATION = "/jsp/registration_confirmation.jsp"; } package gwtapp.client.widget; import static gwtapp.client.consts.StrutsLocations; class SomeWidget { String nextStrutsLocation = REGISTRATION_CONFIRMATION; } Zheng, Hong wrote: > > Hi all, > > I have been struggling with this problem for a few months now. I am > using GWT with Struts 2 on my website. Following is the configuration > for the registration page: > > <action name="register" class="com....RegistrationAction"> > <result name="input">/jsp/registration.jsp</result> > <result > name="success">/jsp/registration_confirmation.jsp</result> > </action> > > registration.jsp contains a form coded using GWT. After > RegistrationAction receives and processes data from the form, it sends > back a JSON string. If everything is good, JSON will contain a > "redirect" property that points to "/jsp/registration_confirmation.jsp". > When GWT codes sees this "redirect" property in returned JSON, it will > redirect browser to the new page accordingly. > > The issue here is that I don't want to hard-code > "/jsp/registration_confirmation.jsp" again in my RegistrationAction > class, because I already defined that in struts.xml and that's where it > should be defined. Yet, I still need to pass that URL to GWT for > redirection. Is there a way in Struts 2 that would translate a result > name("success") to the corresponding result > value("/jsp/registration_confirmation.jsp")? > > Many thanks! > Hong Zheng > > P.S. I am aware that one solution would be to define another Action, > such as RegistrationConfirmationAction. But that's not really a very > elegant solution. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > -- View this message in context: http://old.nabble.com/Struts-2-Result-%2B-GWT-tp26735858p26741060.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org