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
> > <html:submit> 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 <bean:message> 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:
> > > -------------------
> > >             <tr>
> > >        <td colspan="5" align="right">
> > >           <html:submit styleClass="bodyform">
> > >             <bean:message key="button.cancel"/>
> > >           </html:submit>&nbsp;</td>
> > >        <td>
> > >           <html:submit styleClass="bodyform">
> > >             <bean:message key="button.edit"/>
> > >           </html:submit>&nbsp;</td>
> > >        <td>
> > >           <html:submit styleClass="bodyform">
> > >             <bean:message key="button.confirm"/>
> > >           </html:submit></td>
> > >       </tr>
> > > -------------------
> > >
> > > 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/



Reply via email to