You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shamdasani Nimmi-ANS004 <AN...@motorola.com> on 2001/06/14 18:52:09 UTC
Having problems passing more than one parameter with
tag
Hi,
I am trying to pass 2 parameters with html:link. Since it is not legal to use the same attribute name more than once in the same tag, I created another reference 'tempId' to my 'submitQuotesForm' bean using <bean:define> tag but I am only getting the last param 'supplier_seq' added to my link.
Here's my JSP code:
<bean:define id="tempId" name="submitQuotesForm" type="com.motorola.mms.msqc.beans.SubmitQuotesForm" />
<html:link href="part.do"
paramId="motorola_part" paramName="submitQuotesForm" paramProperty="partNbr"
paramId="supplier_seq" paramName="tempId" paramProperty="supplierSeq" >
<bean:write name="submitQuotesForm" property= "partNbr" />
</html:link>
What am I doing wrong?
-Nimmi
Re: Having problems passing more than one parameter with tag
Posted by Ted Husted <hu...@apache.org>.
I think you would need to use a map here.
< http://jakarta.apache.org/struts/struts-html.html#link >
"Normally, the hyperlink you specify with one of the attributes
described in the previous
paragraph will be left unchanged (other than URL rewriting if
necessary). 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."
Shamdasani Nimmi-ANS004 wrote:
> I am trying to pass 2 parameters with html:link. Since it is not legal to use the same attribute name more than once in the same tag, I created another reference 'tempId' to my 'submitQuotesForm' bean using <bean:define> tag but I am only getting the last param 'supplier_seq' added to my link.
Re: Having problems passing more than one parameter with
tag
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 14 Jun 2001, Shamdasani Nimmi-ANS004 wrote:
> Hi,
>
> I am trying to pass 2 parameters with html:link. Since it is not legal to use the same attribute name more than once in the same tag, I created another reference 'tempId' to my 'submitQuotesForm' bean using <bean:define> tag but I am only getting the last param 'supplier_seq' added to my link.
>
> Here's my JSP code:
>
> <bean:define id="tempId" name="submitQuotesForm" type="com.motorola.mms.msqc.beans.SubmitQuotesForm" />
> <html:link href="part.do"
> paramId="motorola_part" paramName="submitQuotesForm" paramProperty="partNbr"
> paramId="supplier_seq" paramName="tempId" paramProperty="supplierSeq" >
> <bean:write name="submitQuotesForm" property= "partNbr" />
> </html:link>
>
Using "paramId" and "paramName" only works if you want to add a *single*
parameter to the link. XML does not allow you to specify the same
attributes twice in a single tag.
If you want to add multiple parameters, use the following approach:
* Create a Map (such as a HashMap or TreeMap) where the keys
are the parameter names and the values are either String (for
a single parameter value) or array of String (for multiple
parameter value).
* Use <bean:define> or some other technique to introduce this
object into some appropriate scope. I tend to do this in
my Actions (or business logic that they delegate to).
* Code your link tag like this:
<bean:define id="parametersMap" .../>
<html:link href="part.do" name="parametersMap">
...
</html:link>
>
> What am I doing wrong?
>
> -Nimmi
>
>
Craig