Re: Access to ApplicationResources.properties from Action class?

2001-03-13 Thread Mikael Eriksson


 Your right of course. Seems that I answered the question a bit too
quickly, my eyes focues on the code example and I lept to conclusions
from that :-(


 Regards
 Mikael

Martijn Spronk wrote:

> > I think that the best thing to do would be to not use the text of
> >the button at all. If you use the text you will need to change the
> >code as well if you decide to change the text on the button by
> >editing the property file. (And if you get internationalization into
> >the picture it will be even worse.)
>
> I disagree on this.
>
> By accessing the properties file I am actually avoiding having
> to modify the code if the button text changes. After all, I am accessing
> the property from the JSP using a tag, and what I try to do in the perform
> method is the same: access the value of the property.




Re: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Maya Muchnik

David,

Please clarify for me. I am trying use your application for validation and display
different error depending on a selected language. It is 05 release. Your
RegistrationAction.java or MultiRegistrationAction.java calls
Locale locale = getLocale(request);
but it is not used in the source code (directly). Maybe I am missing something. Your
have 2 properties files depending on the language. Does MessageResources use them?

Thanks,

Maya

David Winterfeldt wrote:

> >From your action class you can call.
>
> MessageResources messages = getResources();
> String message = messages.get(locale, "resource.key");
>
> See the API docs for all of the different ways to
> retrieve a message resource.
> http://jakarta.apache.org/struts/api/org/apache/struts/util/MessageResources.html
>
> David
>
> --- Mikael Eriksson <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> >  I think that the best thing to do would be to not
> > use the text of
> > the button at all. If you use the text you will need
> > to change the
> > code as well if you decide to change the text on the
> > button by
> > editing the property file. (And if you get
> > internationalization into
> > the picture it will be even worse.)
> >
> > I think the solution would be to have different
> > names on the
> > buttons (using the 'property' attribute of the
> >  tag) and
> > check the button used by having properties for all
> > the possible names
> > in the Form bean and see which property that is
> > different from null.
> > (Or by doing a request.getParameter() as you do in
> > your example, but
> > I like the automatic way better :-) )
> >
> > The downside of that is of course that you need
> > extra properties in the
> > Form bean class but I still think it will be worth
> > it.
> >
> >  To come back to the original question I do not know
> > how to do it
> > but I guess that it would be possible to find by
> > checking the source
> > of the  tag.
> >
> >  Regards
> >  Mikael
> >
> >
> >
> >
> > Martijn Spronk wrote:
> >
> > > Hi all,
> > >
> > > I'm pretty new to struts, and just started
> > developing a fairly
> > > simple app, however taking a bit beyond the
> > standard example functionality.
> > >
> > > I have a (probably) pretty simple question:
> > > I'm in the perform method of the Action class,
> > processing a form submit, but
> > > want to
> > > forward to different mappings depending on which
> > button was pressed.
> > > In the JSP I am using the
> > ApplicationResources.properties file to create the
> > > button text for the
> > > different buttons, so now I need to access this
> > text also to determine which
> > > action to
> > > take.
> > >
> > > So how do I access the descriptions from the
> > properties file in the Action
> > > class?
> > >
> > > my form:
> > > ---
> > > 
> > >
> > >   
> > > 
> > >    
> > >
> > >   
> > > 
> > >    
> > >
> > >   
> > > 
> > >   
> > >   
> > > ---
> > >
> > > So what do I put at the ... in the following
> > fragment of the perform()
> > > method to
> > > be able to get the textual value of the
> > button.cancel and button.edit?
> > > ---
> > > String submit = request.getParameter("submit");
> > > // Forward control depending on which button was
> > pressed
> > > if (submit.equals(...))
> > > return (mapping.findForward("cancel"))
> > > else if (submit.equals(...))
> > > return (mapping.findForward("edit"))
> > > ---
> > >
> > > Thanks,
> > > Martijn.
> >
>
> __
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices.
> http://auctions.yahoo.com/




RE: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Martijn Spronk

>I'm also new to struts, could you post the relavent portion of your
>ApplicationResources.properties file for me.  I'm interested in how your
>code works if you want to have the button be in French or whatever.

Sorry Marty, I am not using internationalization in
any way. My properties file is simply a modification of the
one that comes with the struts-example app.

PS Does everyone on the mailing list receive a copy of their reply 
twice? (One right away and 10 minutes later again)

Martijn Spronk wrote:

> >From your action class you can call.
> >
> >MessageResources messages = getResources();
> >String message = messages.get(locale, "resource.key");
>
> Thanks, that did the job.
>
> PS The method is getMessage(), not get().
>
> --- Mikael Eriksson <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> >  I think that the best thing to do would be to not
> > use the text of
> > the button at all. If you use the text you will need
> > to change the
> > code as well if you decide to change the text on the
> > button by
> > editing the property file. (And if you get
> > internationalization into
> > the picture it will be even worse.)
> >
> > I think the solution would be to have different
> > names on the
> > buttons (using the 'property' attribute of the
> >  tag) and
> > check the button used by having properties for all
> > the possible names
> > in the Form bean and see which property that is
> > different from null.
> > (Or by doing a request.getParameter() as you do in
> > your example, but
> > I like the automatic way better :-) )
> >
> > The downside of that is of course that you need
> > extra properties in the
> > Form bean class but I still think it will be worth
> > it.
> >
> >  To come back to the original question I do not know
> > how to do it
> > but I guess that it would be possible to find by
> > checking the source
> > of the  tag.
> >
> >  Regards
> >  Mikael
> >
> >
> >
> >
> > Martijn Spronk wrote:
> >
> > > Hi all,
> > >
> > > I'm pretty new to struts, and just started
> > developing a fairly
> > > simple app, however taking a bit beyond the
> > standard example functionality.
> > >
> > > I have a (probably) pretty simple question:
> > > I'm in the perform method of the Action class,
> > processing a form submit, but
> > > want to
> > > forward to different mappings depending on which
> > button was pressed.
> > > In the JSP I am using the
> > ApplicationResources.properties file to create the
> > > button text for the
> > > different buttons, so now I need to access this
> > text also to determine which
> > > action to
> > > take.
> > >
> > > So how do I access the descriptions from the
> > properties file in the Action
> > > class?
> > >
> > > my form:
> > > ---
> > > 
> > >
> > >   
> > > 
> > >    
> > >
> > >   
> > > 
> > >    
> > >
> > >   
> > > 
> > >   
> > >   
> > > ---
> > >
> > > So what do I put at the ... in the following
> > fragment of the perform()
> > > method to
> > > be able to get the textual value of the
> > button.cancel and button.edit?
> > > ---
> > > String submit = request.getParameter("submit");
> > > // Forward control depending on which button was
> > pressed
> > > if (submit.equals(...))
> > > return (mapping.findForward("cancel"))
> > > else if (submit.equals(...))
> > > return (mapping.findForward("edit"))
> > > ---
> > >
> > > Thanks,
> > > Martijn.
> >
>
> __
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices.
> http://auctions.yahoo.com/





Re: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Marty Fisher

Martijn,

I'm also new to struts, could you post the relavent portion of your
ApplicationResources.properties file for me.  I'm interested in how your
code works if you want to have the button be in French or whatever.

Thanks,
Marty Fisher

Martijn Spronk wrote:

> >From your action class you can call.
> >
> >MessageResources messages = getResources();
> >String message = messages.get(locale, "resource.key");
>
> Thanks, that did the job.
>
> PS The method is getMessage(), not get().
>
> --- Mikael Eriksson <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> >  I think that the best thing to do would be to not
> > use the text of
> > the button at all. If you use the text you will need
> > to change the
> > code as well if you decide to change the text on the
> > button by
> > editing the property file. (And if you get
> > internationalization into
> > the picture it will be even worse.)
> >
> > I think the solution would be to have different
> > names on the
> > buttons (using the 'property' attribute of the
> >  tag) and
> > check the button used by having properties for all
> > the possible names
> > in the Form bean and see which property that is
> > different from null.
> > (Or by doing a request.getParameter() as you do in
> > your example, but
> > I like the automatic way better :-) )
> >
> > The downside of that is of course that you need
> > extra properties in the
> > Form bean class but I still think it will be worth
> > it.
> >
> >  To come back to the original question I do not know
> > how to do it
> > but I guess that it would be possible to find by
> > checking the source
> > of the  tag.
> >
> >  Regards
> >  Mikael
> >
> >
> >
> >
> > Martijn Spronk wrote:
> >
> > > Hi all,
> > >
> > > I'm pretty new to struts, and just started
> > developing a fairly
> > > simple app, however taking a bit beyond the
> > standard example functionality.
> > >
> > > I have a (probably) pretty simple question:
> > > I'm in the perform method of the Action class,
> > processing a form submit, but
> > > want to
> > > forward to different mappings depending on which
> > button was pressed.
> > > In the JSP I am using the
> > ApplicationResources.properties file to create the
> > > button text for the
> > > different buttons, so now I need to access this
> > text also to determine which
> > > action to
> > > take.
> > >
> > > So how do I access the descriptions from the
> > properties file in the Action
> > > class?
> > >
> > > my form:
> > > ---
> > > 
> > >
> > >   
> > > 
> > >    
> > >
> > >   
> > > 
> > >    
> > >
> > >   
> > > 
> > >   
> > >   
> > > ---
> > >
> > > So what do I put at the ... in the following
> > fragment of the perform()
> > > method to
> > > be able to get the textual value of the
> > button.cancel and button.edit?
> > > ---
> > > String submit = request.getParameter("submit");
> > > // Forward control depending on which button was
> > pressed
> > > if (submit.equals(...))
> > > return (mapping.findForward("cancel"))
> > > else if (submit.equals(...))
> > > return (mapping.findForward("edit"))
> > > ---
> > >
> > > Thanks,
> > > Martijn.
> >
>
> __
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices.
> http://auctions.yahoo.com/






RE: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Martijn Spronk

>From your action class you can call.
>
>MessageResources messages = getResources();
>String message = messages.get(locale, "resource.key");

Thanks, that did the job.

PS The method is getMessage(), not get().





--- Mikael Eriksson <[EMAIL PROTECTED]> wrote:
> Hello,
> 
>  I think that the best thing to do would be to not
> use the text of
> the button at all. If you use the text you will need
> to change the
> code as well if you decide to change the text on the
> button by
> editing the property file. (And if you get
> internationalization into
> the picture it will be even worse.)
> 
> I think the solution would be to have different
> names on the
> buttons (using the 'property' attribute of the
>  tag) and
> check the button used by having properties for all
> the possible names
> in the Form bean and see which property that is
> different from null.
> (Or by doing a request.getParameter() as you do in
> your example, but
> I like the automatic way better :-) )
> 
> The downside of that is of course that you need
> extra properties in the
> Form bean class but I still think it will be worth
> it.
> 
>  To come back to the original question I do not know
> how to do it
> but I guess that it would be possible to find by
> checking the source
> of the  tag.
> 
>  Regards
>  Mikael
> 
> 
> 
> 
> Martijn Spronk wrote:
> 
> > Hi all,
> >
> > I'm pretty new to struts, and just started
> developing a fairly
> > simple app, however taking a bit beyond the
> standard example functionality.
> >
> > I have a (probably) pretty simple question:
> > I'm in the perform method of the Action class,
> processing a form submit, but
> > want to
> > forward to different mappings depending on which
> button was pressed.
> > In the JSP I am using the
> ApplicationResources.properties file to create the
> > button text for the
> > different buttons, so now I need to access this
> text also to determine which
> > action to
> > take.
> >
> > So how do I access the descriptions from the
> properties file in the Action
> > class?
> >
> > my form:
> > ---
> > 
> >
> >   
> > 
> >    
> >
> >   
> > 
> >    
> >
> >   
> > 
> >   
> >   
> > ---
> >
> > So what do I put at the ... in the following
> fragment of the perform()
> > method to
> > be able to get the textual value of the
> button.cancel and button.edit?
> > ---
> > String submit = request.getParameter("submit");
> > // Forward control depending on which button was
> pressed
> > if (submit.equals(...))
> > return (mapping.findForward("cancel"))
> > else if (submit.equals(...))
> > return (mapping.findForward("edit"))
> > ---
> >
> > Thanks,
> > Martijn.
> 


__
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/



Re: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread David Winterfeldt

>From your action class you can call.

MessageResources messages = getResources();
String message = messages.get(locale, "resource.key");

See the API docs for all of the different ways to
retrieve a message resource.
http://jakarta.apache.org/struts/api/org/apache/struts/util/MessageResources.html

David

--- Mikael Eriksson <[EMAIL PROTECTED]> wrote:
> Hello,
> 
>  I think that the best thing to do would be to not
> use the text of
> the button at all. If you use the text you will need
> to change the
> code as well if you decide to change the text on the
> button by
> editing the property file. (And if you get
> internationalization into
> the picture it will be even worse.)
> 
> I think the solution would be to have different
> names on the
> buttons (using the 'property' attribute of the
>  tag) and
> check the button used by having properties for all
> the possible names
> in the Form bean and see which property that is
> different from null.
> (Or by doing a request.getParameter() as you do in
> your example, but
> I like the automatic way better :-) )
> 
> The downside of that is of course that you need
> extra properties in the
> Form bean class but I still think it will be worth
> it.
> 
>  To come back to the original question I do not know
> how to do it
> but I guess that it would be possible to find by
> checking the source
> of the  tag.
> 
>  Regards
>  Mikael
> 
> 
> 
> 
> Martijn Spronk wrote:
> 
> > Hi all,
> >
> > I'm pretty new to struts, and just started
> developing a fairly
> > simple app, however taking a bit beyond the
> standard example functionality.
> >
> > I have a (probably) pretty simple question:
> > I'm in the perform method of the Action class,
> processing a form submit, but
> > want to
> > forward to different mappings depending on which
> button was pressed.
> > In the JSP I am using the
> ApplicationResources.properties file to create the
> > button text for the
> > different buttons, so now I need to access this
> text also to determine which
> > action to
> > take.
> >
> > So how do I access the descriptions from the
> properties file in the Action
> > class?
> >
> > my form:
> > ---
> > 
> >
> >   
> > 
> >    
> >
> >   
> > 
> >    
> >
> >   
> > 
> >   
> >   
> > ---
> >
> > So what do I put at the ... in the following
> fragment of the perform()
> > method to
> > be able to get the textual value of the
> button.cancel and button.edit?
> > ---
> > String submit = request.getParameter("submit");
> > // Forward control depending on which button was
> pressed
> > if (submit.equals(...))
> > return (mapping.findForward("cancel"))
> > else if (submit.equals(...))
> > return (mapping.findForward("edit"))
> > ---
> >
> > Thanks,
> > Martijn.
> 


__
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/



RE: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Martijn Spronk

> I think that the best thing to do would be to not use the text of
>the button at all. If you use the text you will need to change the
>code as well if you decide to change the text on the button by
>editing the property file. (And if you get internationalization into
>the picture it will be even worse.)

I disagree on this. 

By accessing the properties file I am actually avoiding having
to modify the code if the button text changes. After all, I am accessing
the property from the JSP using a tag, and what I try to do in the perform 
method is the same: access the value of the property. 

I won't have a static text in my method, I will have something like 
getProperty("button.edit") in the conditional statement.
So a change of the property value will be mapped to both the JSP tag,
and to the (dynamic) conditional statement in the perform method.




Martijn Spronk wrote:

> Hi all,
>
> I'm pretty new to struts, and just started developing a fairly
> simple app, however taking a bit beyond the standard example
functionality.
>
> I have a (probably) pretty simple question:
> I'm in the perform method of the Action class, processing a form submit,
but
> want to
> forward to different mappings depending on which button was pressed.
> In the JSP I am using the ApplicationResources.properties file to create
the
> button text for the
> different buttons, so now I need to access this text also to determine
which
> action to
> take.
>
> So how do I access the descriptions from the properties file in the Action
> class?
>
> my form:
> ---
> 
>
>   
> 
>    
>
>   
> 
>    
>
>   
> 
>   
>   
> ---
>
> So what do I put at the ... in the following fragment of the perform()
> method to
> be able to get the textual value of the button.cancel and button.edit?
> ---
> String submit = request.getParameter("submit");
> // Forward control depending on which button was pressed
> if (submit.equals(...))
> return (mapping.findForward("cancel"))
> else if (submit.equals(...))
> return (mapping.findForward("edit"))
> ---
>
> Thanks,
> Martijn.



Re: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Mikael Eriksson

Hello,

 I think that the best thing to do would be to not use the text of
the button at all. If you use the text you will need to change the
code as well if you decide to change the text on the button by
editing the property file. (And if you get internationalization into
the picture it will be even worse.)

I think the solution would be to have different names on the
buttons (using the 'property' attribute of the  tag) and
check the button used by having properties for all the possible names
in the Form bean and see which property that is different from null.
(Or by doing a request.getParameter() as you do in your example, but
I like the automatic way better :-) )

The downside of that is of course that you need extra properties in the
Form bean class but I still think it will be worth it.

 To come back to the original question I do not know how to do it
but I guess that it would be possible to find by checking the source
of the  tag.

 Regards
 Mikael




Martijn Spronk wrote:

> Hi all,
>
> I'm pretty new to struts, and just started developing a fairly
> simple app, however taking a bit beyond the standard example functionality.
>
> I have a (probably) pretty simple question:
> I'm in the perform method of the Action class, processing a form submit, but
> want to
> forward to different mappings depending on which button was pressed.
> In the JSP I am using the ApplicationResources.properties file to create the
> button text for the
> different buttons, so now I need to access this text also to determine which
> action to
> take.
>
> So how do I access the descriptions from the properties file in the Action
> class?
>
> my form:
> ---
> 
>
>   
> 
>    
>
>   
> 
>    
>
>   
> 
>   
>   
> ---
>
> So what do I put at the ... in the following fragment of the perform()
> method to
> be able to get the textual value of the button.cancel and button.edit?
> ---
> String submit = request.getParameter("submit");
> // Forward control depending on which button was pressed
> if (submit.equals(...))
> return (mapping.findForward("cancel"))
> else if (submit.equals(...))
> return (mapping.findForward("edit"))
> ---
>
> Thanks,
> Martijn.




RE: Access to ApplicationResources.properties from Action class?

2001-03-12 Thread James Stephens

how to unsubscribe please

-Original Message-
From: Martijn Spronk [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 13:22
To: '[EMAIL PROTECTED]'
Subject: Access to ApplicationResources.properties from Action class?


Hi all,

I'm pretty new to struts, and just started developing a fairly
simple app, however taking a bit beyond the standard example
functionality.

I have a (probably) pretty simple question:
I'm in the perform method of the Action class, processing a form submit,
but
want to 
forward to different mappings depending on which button was pressed.
In the JSP I am using the ApplicationResources.properties file to create
the
button text for the
different buttons, so now I need to access this text also to determine
which
action to
take. 

So how do I access the descriptions from the properties file in the
Action
class?

my form:
---

   
  

   
   
  

   
   
  

  
  
---

So what do I put at the ... in the following fragment of the perform()
method to
be able to get the textual value of the button.cancel and button.edit?
---
String submit = request.getParameter("submit");
// Forward control depending on which button was pressed
if (submit.equals(...))
return (mapping.findForward("cancel"))
else if (submit.equals(...))
return (mapping.findForward("edit"))
---

Thanks,
Martijn.



Access to ApplicationResources.properties from Action class?

2001-03-12 Thread Martijn Spronk

Hi all,

I'm pretty new to struts, and just started developing a fairly
simple app, however taking a bit beyond the standard example functionality.

I have a (probably) pretty simple question:
I'm in the perform method of the Action class, processing a form submit, but
want to 
forward to different mappings depending on which button was pressed.
In the JSP I am using the ApplicationResources.properties file to create the
button text for the
different buttons, so now I need to access this text also to determine which
action to
take. 

So how do I access the descriptions from the properties file in the Action
class?

my form:
---

   
  

   
   
  

   
   
  

  
  
---

So what do I put at the ... in the following fragment of the perform()
method to
be able to get the textual value of the button.cancel and button.edit?
---
String submit = request.getParameter("submit");
// Forward control depending on which button was pressed
if (submit.equals(...))
return (mapping.findForward("cancel"))
else if (submit.equals(...))
return (mapping.findForward("edit"))
---

Thanks,
Martijn.