You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dennis Atkinson <de...@yahoo.com> on 2009/07/29 18:44:59 UTC

New to Struts, a Question

Hello everyone.

I am new to Struts2, and I like what I see so far.  I want to use it for all my web programming.

I have a question, and I hope I don't sound too foolish for asking it.

I created a login screen, which has two fields, "id" and "password".  I fill those fields, press the "Login" button, and it goes to the "LoginAction" class, which validates everything, and I return "success".  This invokes "userDisplay.jsp" which writes the user's information out to the screen.

When the userDisplay screen appeared, I saw the field descriptions but I didn't see any data.  It seems like the getter methods for the fields are not being called in the "UserDisplayAction" class.  When I add the getter methods to the "LoginAction" class, the data appears.

It seems to me that the "LoginAction" class is still in control.  So in theory, if I have an action class that invokes (via a pick list or a series of buttons) a way of displaying a dozen different tables by routing to a dozen different jsp files, that action class will need getter methods for every field in every one of these tables?  Am I reading this right?

I hope one of the experts can clear this up for me.

Thanks in advance,
Dennis Atkinson


      

Re: Internationalization and SEO

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Have you seen URLRewrite Filter, it will enable you to set request
parameters based on URL. For example you can have
www.mydomain.com/en/myPage.htm remap to
www.mydomain.com/myPage.htm?locale=en and likewise for the others.

It¹s one of the handiest tools for web.

Z.
> 
> Hello,
> 
> I have a question relating to serving international content that I hope
> someone can help with.
> 
> It is kind of leaning towards an SEO question, but it does relate to
> Struts in terms of how I can use Struts 2 to control page direction
> because of language selection.
> 
> In terms of SEO, I am guessing that serving the content for three
> languages on one page, would be bad for SEO.
> 
> For example, serving English, French and German versions for a page all
> on the same URL:
> 
> www.mydomain.com/myPage.htm
> 
> This is possible of course creating and using the corresponding language
> resource bundles.  Struts 2 would serve up the correct content based on
> the browser locale setting.
> 
> However, looking around Googles knowledgebase, it would be better to have:
> 
> www.mydomain.com/en/myPage.htm
> www.mydomain.com/fr/myPage.htm
> www.mydomain.com/de/myPage.htm
> 
> How can I configure struts to work in this way, ie redirect a user to a
> subdirectory tree based on the language locale set in their browser.
> 
> Thanks for any thoughts.
> Robin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


Internationalization and SEO

Posted by Robin Mannering <ro...@mtndesigns.co.uk>.
Hello,

I have a question relating to serving international content that I hope 
someone can help with.

It is kind of leaning towards an SEO question, but it does relate to 
Struts in terms of how I can use Struts 2 to control page direction 
because of language selection.

In terms of SEO, I am guessing that serving the content for three 
languages on one page, would be bad for SEO.

For example, serving English, French and German versions for a page all 
on the same URL:

www.mydomain.com/myPage.htm

This is possible of course creating and using the corresponding language 
resource bundles.  Struts 2 would serve up the correct content based on 
the browser locale setting.

However, looking around Googles knowledgebase, it would be better to have:

www.mydomain.com/en/myPage.htm
www.mydomain.com/fr/myPage.htm
www.mydomain.com/de/myPage.htm

How can I configure struts to work in this way, ie redirect a user to a 
subdirectory tree based on the language locale set in their browser.

Thanks for any thoughts.
Robin


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


Re: New to Struts, a Question

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Thomas,
yes it is picking it from there.
Empty name is same as name="success".

Best greetings,
Paweł Wielgus.

2009/7/30 Thomas Sattler <to...@gmail.com>:
> In my struts.xml file, I have the UserDisplayAction class and a blank (no
> "name=") result for userDisplay.jsp.  Does it pick up from there?
>
>
>
> On Wed, Jul 29, 2009 at 8:40 PM, Dave Newton <ne...@yahoo.com> wrote:
>
>> Dennis Atkinson wrote:
>>
>>> Dave,
>>>
>>> OK, I  can make it work.  I just don't understand WHY it works.
>>>
>>> If I change to this: <a href="/betaSystem/userDisplay.action">My
>>> Acccount</a>
>>>
>>> I get exactly what I expect; the screen loads with the data filled in
>>> properly.
>>>
>>> But what I don't understand is how Struts knows to load
>>> userDisplay.jsp.  I assume it parses the "userDisplay" out of the url
>>> and appends the ".jsp" to the end, so as long as I have these names
>>> the same (other than the suffix), this will work?
>>>
>>
>> You don't have a user display action configured via XML or annotations?
>>
>>
>> Dave
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

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


Re: New to Struts, a Question

Posted by Dave Newton <ne...@yahoo.com>.
Dennis Atkinson wrote:
> I have a follow-up question about this subject (redirecting to an
> Action class rather than a jsp file).
> 
> When I do the redirect, and the target is an Action class with
> validated input fields, when the screen is initially shown, I get
> "... field is required" messages on everything.  Apparently the
> Action class thinks a user submit was done, and so it runs all its
> validations.  This isn't the behavior I would like to see; I tried
> removing the "input" result from struts.xml but that just causes a
> "No result defined" error.
> 
> Does anyone know the trick to this?

If you're redirecting to an action that has validation then you need to 
go specifically to a method that isn't validated, whether by default 
(input, for example, is excluded by default) or by configuration.

Dave

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


Re: New to Struts, a Question

Posted by Dennis Atkinson <de...@yahoo.com>.
I have a follow-up question about this subject (redirecting to an Action class rather than a jsp file).

When I do the redirect, and the target is an Action class with validated input fields, when the screen is initially shown, I get "... field is required" messages on everything.  Apparently the Action class thinks a user submit was done, and so it runs all its validations.  This isn't the behavior I would like to see; I tried removing the "input" result from struts.xml but that just causes a "No result defined" error.

Does anyone know the trick to this?

Thanks,
Dennis





________________________________
From: Dennis Atkinson <de...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thursday, July 30, 2009 1:18:12 PM
Subject: Re: New to Struts, a Question

Thanks to all who helped with this - I understand it better now.

Dennis





________________________________
From: Martin Gainty <mg...@hotmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thursday, July 30, 2009 8:32:01 AM
Subject: RE: New to Struts, a Question


in your config files look for default result assignment with <result tag as in

<result>/userDisplay.jsp</result>
http://struts.apache.org/2.0.14/docs/result-configuration.html

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 29 Jul 2009 21:14:24 -0400
> Subject: Re: New to Struts, a Question
> From: tomsattler@gmail.com
> To: user@struts.apache.org
> 
> In my struts.xml file, I have the UserDisplayAction class and a blank (no
> "name=") result for userDisplay.jsp.  Does it pick up from there?
> 
> 
> 
> On Wed, Jul 29, 2009 at 8:40 PM, Dave Newton <ne...@yahoo.com> wrote:
> 
> > Dennis Atkinson wrote:
> >
> >> Dave,
> >>
> >> OK, I  can make it work.  I just don't understand WHY it works.
> >>
> >> If I change to this: <a href="/betaSystem/userDisplay.action">My
> >> Acccount</a>
> >>
> >> I get exactly what I expect; the screen loads with the data filled in
> >> properly.
> >>
> >> But what I don't understand is how Struts knows to load
> >> userDisplay.jsp.  I assume it parses the "userDisplay" out of the url
> >> and appends the ".jsp" to the end, so as long as I have these names
> >> the same (other than the suffix), this will work?
> >>
> >
> > You don't have a user display action configured via XML or annotations?
> >
> >
> > Dave
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >

_________________________________________________________________
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TXT_MLOGEN_Local_Local_Restaurants_1x1


      

Re: New to Struts, a Question

Posted by Dennis Atkinson <de...@yahoo.com>.
Thanks to all who helped with this - I understand it better now.

Dennis





________________________________
From: Martin Gainty <mg...@hotmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thursday, July 30, 2009 8:32:01 AM
Subject: RE: New to Struts, a Question


in your config files look for default result assignment with <result tag as in

<result>/userDisplay.jsp</result>
http://struts.apache.org/2.0.14/docs/result-configuration.html

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 29 Jul 2009 21:14:24 -0400
> Subject: Re: New to Struts, a Question
> From: tomsattler@gmail.com
> To: user@struts.apache.org
> 
> In my struts.xml file, I have the UserDisplayAction class and a blank (no
> "name=") result for userDisplay.jsp.  Does it pick up from there?
> 
> 
> 
> On Wed, Jul 29, 2009 at 8:40 PM, Dave Newton <ne...@yahoo.com> wrote:
> 
> > Dennis Atkinson wrote:
> >
> >> Dave,
> >>
> >> OK, I  can make it work.  I just don't understand WHY it works.
> >>
> >> If I change to this: <a href="/betaSystem/userDisplay.action">My
> >> Acccount</a>
> >>
> >> I get exactly what I expect; the screen loads with the data filled in
> >> properly.
> >>
> >> But what I don't understand is how Struts knows to load
> >> userDisplay.jsp.  I assume it parses the "userDisplay" out of the url
> >> and appends the ".jsp" to the end, so as long as I have these names
> >> the same (other than the suffix), this will work?
> >>
> >
> > You don't have a user display action configured via XML or annotations?
> >
> >
> > Dave
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >

_________________________________________________________________
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TXT_MLOGEN_Local_Local_Restaurants_1x1


      

RE: New to Struts, a Question

Posted by Martin Gainty <mg...@hotmail.com>.
in your config files look for default result assignment with <result tag as in

<result>/userDisplay.jsp</result>
http://struts.apache.org/2.0.14/docs/result-configuration.html

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 29 Jul 2009 21:14:24 -0400
> Subject: Re: New to Struts, a Question
> From: tomsattler@gmail.com
> To: user@struts.apache.org
> 
> In my struts.xml file, I have the UserDisplayAction class and a blank (no
> "name=") result for userDisplay.jsp.  Does it pick up from there?
> 
> 
> 
> On Wed, Jul 29, 2009 at 8:40 PM, Dave Newton <ne...@yahoo.com> wrote:
> 
> > Dennis Atkinson wrote:
> >
> >> Dave,
> >>
> >> OK, I  can make it work.  I just don't understand WHY it works.
> >>
> >> If I change to this: <a href="/betaSystem/userDisplay.action">My
> >> Acccount</a>
> >>
> >> I get exactly what I expect; the screen loads with the data filled in
> >> properly.
> >>
> >> But what I don't understand is how Struts knows to load
> >> userDisplay.jsp.  I assume it parses the "userDisplay" out of the url
> >> and appends the ".jsp" to the end, so as long as I have these names
> >> the same (other than the suffix), this will work?
> >>
> >
> > You don't have a user display action configured via XML or annotations?
> >
> >
> > Dave
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >

_________________________________________________________________
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TXT_MLOGEN_Local_Local_Restaurants_1x1

Re: New to Struts, a Question

Posted by Thomas Sattler <to...@gmail.com>.
In my struts.xml file, I have the UserDisplayAction class and a blank (no
"name=") result for userDisplay.jsp.  Does it pick up from there?



On Wed, Jul 29, 2009 at 8:40 PM, Dave Newton <ne...@yahoo.com> wrote:

> Dennis Atkinson wrote:
>
>> Dave,
>>
>> OK, I  can make it work.  I just don't understand WHY it works.
>>
>> If I change to this: <a href="/betaSystem/userDisplay.action">My
>> Acccount</a>
>>
>> I get exactly what I expect; the screen loads with the data filled in
>> properly.
>>
>> But what I don't understand is how Struts knows to load
>> userDisplay.jsp.  I assume it parses the "userDisplay" out of the url
>> and appends the ".jsp" to the end, so as long as I have these names
>> the same (other than the suffix), this will work?
>>
>
> You don't have a user display action configured via XML or annotations?
>
>
> Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: New to Struts, a Question

Posted by Dave Newton <ne...@yahoo.com>.
Dennis Atkinson wrote:
> Dave,
> 
> OK, I  can make it work.  I just don't understand WHY it works.
> 
> If I change to this: <a href="/betaSystem/userDisplay.action">My
> Acccount</a>
> 
> I get exactly what I expect; the screen loads with the data filled in
> properly.
> 
> But what I don't understand is how Struts knows to load
> userDisplay.jsp.  I assume it parses the "userDisplay" out of the url
> and appends the ".jsp" to the end, so as long as I have these names
> the same (other than the suffix), this will work?

You don't have a user display action configured via XML or annotations?

Dave

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


Re: New to Struts, a Question

Posted by Dennis Atkinson <de...@yahoo.com>.
Dave,

OK, I  can make it work.  I just don't understand WHY it works.

If I change to this:
<a href="/betaSystem/userDisplay.action">My Acccount</a>

I get exactly what I expect; the screen loads with the data filled in properly.

But what I don't understand is how Struts knows to load userDisplay.jsp.  I assume it parses the "userDisplay" out of the url and appends the ".jsp" to the end, so as long as I have these names the same (other than the suffix), this will work?

Thanks,
Dennis





________________________________
From: Dave Newton <ne...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wednesday, July 29, 2009 5:49:04 PM
Subject: Re: New to Struts, a Question

Dennis Atkinson wrote:
> The menu says:
> <a href="/betaSystem/jsp/userDisplay.jsp">My Acccount</a>
> 
> Can I direct this to an action class, rather than to a jsp file?

Action URLs are URLs like any other, including a JSP.

Dave

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


      

Re: New to Struts, a Question

Posted by Dave Newton <ne...@yahoo.com>.
Dennis Atkinson wrote:
> The menu says:
> <a href="/betaSystem/jsp/userDisplay.jsp">My Acccount</a>
> 
> Can I direct this to an action class, rather than to a jsp file?

Action URLs are URLs like any other, including a JSP.

Dave

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


Re: New to Struts, a Question

Posted by Dennis Atkinson <de...@yahoo.com>.
Burton,

Thanks very much for the reply.  I have tried this and it works great.  I appreciate the assistance.

Is it possible to do the same thing, but on a menu selection?

The menu says:
<a href="/betaSystem/jsp/userDisplay.jsp">My Acccount</a>

Can I direct this to an action class, rather than to a jsp file?





________________________________
From: Burton Rhodes <bu...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wednesday, July 29, 2009 1:13:37 PM
Subject: Re: New to Struts, a Question

I think you want to investigate an 'actionredirect' on 'success'
instead of just displaying the user jsp file. This will 'handoff'
control to your user action.

On 7/29/09, Dennis Atkinson <de...@yahoo.com> wrote:
> Hello everyone.
>
> I am new to Struts2, and I like what I see so far.  I want to use it for all
> my web programming.
>
> I have a question, and I hope I don't sound too foolish for asking it.
>
> I created a login screen, which has two fields, "id" and "password".  I fill
> those fields, press the "Login" button, and it goes to the "LoginAction"
> class, which validates everything, and I return "success".  This invokes
> "userDisplay.jsp" which writes the user's information out to the screen.
>
> When the userDisplay screen appeared, I saw the field descriptions but I
> didn't see any data.  It seems like the getter methods for the fields are
> not being called in the "UserDisplayAction" class.  When I add the getter
> methods to the "LoginAction" class, the data appears.
>
> It seems to me that the "LoginAction" class is still in control.  So in
> theory, if I have an action class that invokes (via a pick list or a series
> of buttons) a way of displaying a dozen different tables by routing to a
> dozen different jsp files, that action class will need getter methods for
> every field in every one of these tables?  Am I reading this right?
>
> I hope one of the experts can clear this up for me.
>
> Thanks in advance,
> Dennis Atkinson
>
>
>

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


      

Re: New to Struts, a Question

Posted by Burton Rhodes <bu...@gmail.com>.
I think you want to investigate an 'actionredirect' on 'success'
instead of just displaying the user jsp file. This will 'handoff'
control to your user action.

On 7/29/09, Dennis Atkinson <de...@yahoo.com> wrote:
> Hello everyone.
>
> I am new to Struts2, and I like what I see so far.  I want to use it for all
> my web programming.
>
> I have a question, and I hope I don't sound too foolish for asking it.
>
> I created a login screen, which has two fields, "id" and "password".  I fill
> those fields, press the "Login" button, and it goes to the "LoginAction"
> class, which validates everything, and I return "success".  This invokes
> "userDisplay.jsp" which writes the user's information out to the screen.
>
> When the userDisplay screen appeared, I saw the field descriptions but I
> didn't see any data.  It seems like the getter methods for the fields are
> not being called in the "UserDisplayAction" class.  When I add the getter
> methods to the "LoginAction" class, the data appears.
>
> It seems to me that the "LoginAction" class is still in control.  So in
> theory, if I have an action class that invokes (via a pick list or a series
> of buttons) a way of displaying a dozen different tables by routing to a
> dozen different jsp files, that action class will need getter methods for
> every field in every one of these tables?  Am I reading this right?
>
> I hope one of the experts can clear this up for me.
>
> Thanks in advance,
> Dennis Atkinson
>
>
>

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