You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Markus <ne...@webeffects.it> on 2006/02/01 12:04:08 UTC

passing parameters

Hi all,

just a simple question.

I would like to pass a single parameter with a <html:link> tag.
I've searched the net, but there I understand that it is only 
possible to pass parameters via beans.

Is the a simpler way to redender the following with <html:link>:

/myAction.do?action=edit

I'm just a little confused now.

Thank You,
Markus


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


Re: AW: passing parameters

Posted by Gareth Evans <ga...@msoft.co.uk>.
if your using the latest servlet spec you can do:

<html:link action="myAction?action=${MyCons.EDIT}">Your Text</html:link>

although, it looks like your trying to access a static field?

I use this trick,

Make you constants class extend java.util.HashMap class

Add this contructor your constant class
public MyCons() {
         // create the internal map using this
         Field[] fields = this.getClass().getDeclaredFields();
         for ( Field field : fields ) {
             try {
                 this.put( field.getName() , (String)field.get( new String() ) );
             }
             catch ( Exception exp ) {}
         }
}

Create an instance of your constants class using:

<jsp:useBean id="myCons" ....

You can then use this within your jsp as shown below:
<html:link action="myAction" paramId="action" paramName="myCons" paramProperty="EDIT"> ...

I think this looks better than using scriptlets and defining temporary strings to hold link locations.

Gareth

Markus Demetz wrote:

> ok thanks,
> but I forgot that it should be dynamically, e.g:
> /myAction?action=<%= MyCons.EDIT %>
> but so it does not work.
> 
> markus
> 
> 
>>-----Ursprüngliche Nachricht-----
>>Von: Gareth Evans [mailto:gareth.evans@msoft.co.uk]
>>Gesendet: Mittwoch, 1. Februar 2006 12:14
>>An: Struts Users Mailing List
>>Betreff: Re: <html:link> passing parameters
>>
>>
>><html:link action="myAction?action=edit">Your Text</html:link>
>>
>>Should do the trick.
>>
>>Note: You do not need the .do
>>
>>Gareth
>>
>>Markus wrote:
>>
>>
>>>Hi all,
>>>
>>>just a simple question.
>>>
>>>I would like to pass a single parameter with a <html:link> tag.
>>>I've searched the net, but there I understand that it is only
>>>possible to pass parameters via beans.
>>>
>>>Is the a simpler way to redender the following with <html:link>:
>>>
>>>/myAction.do?action=edit
>>>
>>>I'm just a little confused now.
>>>
>>>Thank You,
>>>Markus
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>--
>>Gareth Evans
>>
>>MSoft eSolutions Limited
>>Technology Centre
>>Inward Way
>>Rossmore Business Park
>>Ellesmere Port
>>Cheshire
>>CH65 3EN
>>
>>--
>>Tel:    +44 (0)870 0100 704
>>Fax:    +44 (0)870 9010 705
>>E-Mail: gareth@msoft.co.uk
>>Web:    www.msoft.co.uk
>>
>>----------------------------------------------
>>Terms:
>>Please note that any prices quoted within this e-mail are subject to VAT.
>>All program details and code described in this e-mail are subject to
>>copyright © of MSoft eSolutions Limited and remain the intellectual
>>property of MSoft eSolutions Limited.
>>Any proposal or pricing information contained within this e-mail are
>>subject to MSoft eSolutions' Terms and Conditions
>>----------------------------------------------
>>Disclaimer:
>>This message is intended only for use of the addressee. If this message
>>was sent to you in error, please notify the sender and delete this
>>message. MSoft eSolutions Limited cannot accept responsibility
>>for viruses,
>>so please scan attachments. Views expressed in this message do not
>>necessarily reflect those of MSoft eSolutions Limited who will not
>>necessarily be bound by its contents.
>>
>>
>>
>>---------------------------------------------------------------------
>>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
> 
> 

-- 
Gareth Evans

MSoft eSolutions Limited
Technology Centre
Inward Way
Rossmore Business Park
Ellesmere Port
Cheshire
CH65 3EN

-- 
Tel:    +44 (0)870 0100 704
Fax:    +44 (0)870 9010 705
E-Mail: gareth@msoft.co.uk
Web:    www.msoft.co.uk

----------------------------------------------
Terms:
Please note that any prices quoted within this e-mail are subject to VAT.
All program details and code described in this e-mail are subject to
copyright © of MSoft eSolutions Limited and remain the intellectual
property of MSoft eSolutions Limited.
Any proposal or pricing information contained within this e-mail are
subject to MSoft eSolutions' Terms and Conditions
----------------------------------------------
Disclaimer:
This message is intended only for use of the addressee. If this message
was sent to you in error, please notify the sender and delete this
message. MSoft eSolutions Limited cannot accept responsibility for viruses,
so please scan attachments. Views expressed in this message do not
necessarily reflect those of MSoft eSolutions Limited who will not
necessarily be bound by its contents.



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


AW: passing parameters

Posted by Markus Demetz <ne...@webeffects.it>.
ok thanks,
but I forgot that it should be dynamically, e.g:
/myAction?action=<%= MyCons.EDIT %>
but so it does not work.

markus

> -----Ursprüngliche Nachricht-----
> Von: Gareth Evans [mailto:gareth.evans@msoft.co.uk]
> Gesendet: Mittwoch, 1. Februar 2006 12:14
> An: Struts Users Mailing List
> Betreff: Re: <html:link> passing parameters
>
>
> <html:link action="myAction?action=edit">Your Text</html:link>
>
> Should do the trick.
>
> Note: You do not need the .do
>
> Gareth
>
> Markus wrote:
>
> > Hi all,
> >
> > just a simple question.
> >
> > I would like to pass a single parameter with a <html:link> tag.
> > I've searched the net, but there I understand that it is only
> > possible to pass parameters via beans.
> >
> > Is the a simpler way to redender the following with <html:link>:
> >
> > /myAction.do?action=edit
> >
> > I'm just a little confused now.
> >
> > Thank You,
> > Markus
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> --
> Gareth Evans
>
> MSoft eSolutions Limited
> Technology Centre
> Inward Way
> Rossmore Business Park
> Ellesmere Port
> Cheshire
> CH65 3EN
>
> --
> Tel:    +44 (0)870 0100 704
> Fax:    +44 (0)870 9010 705
> E-Mail: gareth@msoft.co.uk
> Web:    www.msoft.co.uk
>
> ----------------------------------------------
> Terms:
> Please note that any prices quoted within this e-mail are subject to VAT.
> All program details and code described in this e-mail are subject to
> copyright © of MSoft eSolutions Limited and remain the intellectual
> property of MSoft eSolutions Limited.
> Any proposal or pricing information contained within this e-mail are
> subject to MSoft eSolutions' Terms and Conditions
> ----------------------------------------------
> Disclaimer:
> This message is intended only for use of the addressee. If this message
> was sent to you in error, please notify the sender and delete this
> message. MSoft eSolutions Limited cannot accept responsibility
> for viruses,
> so please scan attachments. Views expressed in this message do not
> necessarily reflect those of MSoft eSolutions Limited who will not
> necessarily be bound by its contents.
>
>
>
> ---------------------------------------------------------------------
> 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: passing parameters

Posted by Gareth Evans <ga...@msoft.co.uk>.
<html:link action="myAction?action=edit">Your Text</html:link>

Should do the trick.

Note: You do not need the .do

Gareth

Markus wrote:

> Hi all,
> 
> just a simple question.
> 
> I would like to pass a single parameter with a <html:link> tag.
> I've searched the net, but there I understand that it is only 
> possible to pass parameters via beans.
> 
> Is the a simpler way to redender the following with <html:link>:
> 
> /myAction.do?action=edit
> 
> I'm just a little confused now.
> 
> Thank You,
> Markus
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

-- 
Gareth Evans

MSoft eSolutions Limited
Technology Centre
Inward Way
Rossmore Business Park
Ellesmere Port
Cheshire
CH65 3EN

-- 
Tel:    +44 (0)870 0100 704
Fax:    +44 (0)870 9010 705
E-Mail: gareth@msoft.co.uk
Web:    www.msoft.co.uk

----------------------------------------------
Terms:
Please note that any prices quoted within this e-mail are subject to VAT.
All program details and code described in this e-mail are subject to
copyright © of MSoft eSolutions Limited and remain the intellectual
property of MSoft eSolutions Limited.
Any proposal or pricing information contained within this e-mail are
subject to MSoft eSolutions' Terms and Conditions
----------------------------------------------
Disclaimer:
This message is intended only for use of the addressee. If this message
was sent to you in error, please notify the sender and delete this
message. MSoft eSolutions Limited cannot accept responsibility for viruses,
so please scan attachments. Views expressed in this message do not
necessarily reflect those of MSoft eSolutions Limited who will not
necessarily be bound by its contents.



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