However, there are two ways you can append one or more dynamically
defined query parameters to the hyperlink -- specify a single parameter
with the paramId attribute (and its associated attributes to select the
value), or specify the name (and optional property) attributes to select
a java.util.Map bean that contains one or more parameter ids and
corresponding values. 

To specify a single parameter, use the paramId attribute to define the
name of the request parameter to be submitted. To specify the
corresponding value, use one of the following approaches:

Specify only the paramName attribute - The named JSP bean (optionally
scoped by the value of the paramScope attribute) must identify a value
that can be converted to a String. 
Specify both the paramName and paramProperty attributes - The specified
property getter method will be called on the JSP bean identified by the
paramName (and optional paramScope) attributes, in order to select a
value that can be converted to a String. 
If you prefer to specify a java.util.Map that contains all of the
request parameters to be added to the hyperlink, use one of the
following techniques:

Specify only the name attribute - The named JSP bean (optionally scoped
by the value of the scope attribute) must identify a java.util.Map
containing the parameters. 
Specify both name and property attributes - The specified property
getter method will be called on the bean identified by the name (and
optional scope) attributes, in order to return the java.util.Map
containing the parameters.

More http://jakarta.apache.org/struts/userGuide/struts-html.html#link 

Hope this should help 

-----Original Message-----
From: tomansley [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 09, 2004 3:13 PM
To: [EMAIL PROTECTED]
Subject: html:link with multiple parameters

Hi all,

I have a question regarding using the html:link tag where I want to have

multiple parameters added to the link url dynamically.  What I have 
tried to do is have a bean that I am using on the page context have a 
method that returns a Map object that contains all the keys and values 
for the parameters.  Each parameter can be accessed through the 
toString() method as required.

So, for example this is the class with the necessary code:

public class MenuItem {

        /**
         * Empty constructor to conform to JavaBeans convention.
         *
         */
        public MenuItem() {
                // empty default constructor
        }

        private Map params = new HashMap();

        public Map getMenuParams() {
                return params;
        }

........
......

Then, I try to get the html:link tag to call this bean with the 
paramProperty field being "menuParams".  The logic:iterate tag 
enumerates through a set of menuItems which may well be causing
problems.

<jsp:useBean id="menu" scope="session"
class="com.camp.common.menu.Menu"/>

        <logic:iterate id="menuitem" name="menu" property="menuItems">
                <html:link action="/Menu" paramName="menuitem" 
paramProperty="menuParams">
                        <bean:write name="menuitem"
property="menuName"/>
                        </html:link>
                <br>
        </logic:iterate>

Nothing gets inserted as expected.  I do not really want to be creating 
a Map and adding parameters using a scriptlet but would rather have it 
call a Map object from the bean I have created.  Does anybody have any 
better way of doing this or could somebody tell me where I am going
wrong.

I guess at the end of the day, I have searched on the Internet high and 
low for a way of being able to create dynamic parameterized urls using 
html:link within an iteration.

Help anybody!!

Cheers

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to