You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ruben <ru...@yahoo.es> on 2003/05/27 00:06:22 UTC
multiple parameter and map
Hi everybody!
I want to pass to an action from the view 3 parameter, I read on the
documentation that I have to put in a map, and then with a link and
paramName, send to the action.
I do this but in the action I get always null instead the parameter
That is what I do ..
<logic:iterate id="muestraProfesores" name="profesoresList">
<table width="600px" border="0" height="30">
<tr bgcolor="#90ddf0" bordercolor="#0001FF">
<td height="25" width="120px"><font color="#525D76"><bean:write
name="muestraProfesores" property="nombre"/>
</font></td>
<td height="25" width="120px"><font color="#525D76"><bean:write
name="muestraProfesores" property="apellido1"/> </font>
</td>
<td height="25" width="120px"><font color="#525D76"><bean:write
name="muestraProfesores" property="apellido2"/> </font>
</td>
<td height="25" width="120px"><font color="#525D76">
<% Map map = new HashMap();
map.put("nombre", ((prueba)muestraProfesores).getNombre());
map.put("apellido1",((prueba)muestraProfesores).getApellido1());
map.put("apellido2",((prueba)muestraProfesores).getApellido2());
%>
<html:link action="/vistaProfesores.do?method=edicion"
paramName="map" target="princAdmin"> Edicion de profesor
</html:link></font></td>
<td height="25" width="120px"><font color="#525D76"> <html:link
action="/vistaProfesores.do?method=borra" paramName="map"
target="princAdmin"> Borra este profesor </html:link></font></td>
</tr>
</table>
</logic:iterate>
in the action I retrieve the values with ...
(String)request.getParameter("nombre");
(String)request.getParameter("apellido1");
(String)request.getParameter("apellido2");
What am I doing wrong?
PD: is there another possibility rather than use a map to pass multiple
request parameter? (and not using JSTL).
Thanks a lot!!!
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: multiple parameter and map
Posted by Mark Lowe <ma...@talk21.com>.
You need to get the map to an available context
//in your scriplet or action servlet
Map map = new HashMap();
map.put("nombre", ((prueba)muestraProfesores).getNombre());
map.put("apellido1",((prueba)muestraProfesores).getApellido1());
map.put("apellido2",((prueba)muestraProfesores).getApellido2());
request.setAttribute("myMap",map); // or better in pageContext
//jsp
<logic:iterate id="foo" name="map" scope="request">
<html:link name="foo" .... play with the attributes an you'll work it
out
Cheers mark
On Tuesday, May 27, 2003, at 00:06 Europe/Rome, ruben wrote:
> Hi everybody!
>
> I want to pass to an action from the view 3 parameter, I read on the
> documentation that I have to put in a map, and then with a link and
> paramName, send to the action.
> I do this but in the action I get always null instead the parameter
> That is what I do ..
>
> <logic:iterate id="muestraProfesores" name="profesoresList">
> <table width="600px" border="0" height="30">
> <tr bgcolor="#90ddf0" bordercolor="#0001FF">
> <td height="25" width="120px"><font color="#525D76"><bean:write
> name="muestraProfesores" property="nombre"/>
> </font></td>
> <td height="25" width="120px"><font color="#525D76"><bean:write
> name="muestraProfesores" property="apellido1"/> </font>
> </td>
> <td height="25" width="120px"><font color="#525D76"><bean:write
> name="muestraProfesores" property="apellido2"/> </font>
> </td>
> <td height="25" width="120px"><font color="#525D76">
>
> <% Map map = new HashMap();
> map.put("nombre", ((prueba)muestraProfesores).getNombre());
>
> map.put("apellido1",((prueba)muestraProfesores).getApellido1());
>
> map.put("apellido2",((prueba)muestraProfesores).getApellido2());
> %>
>
> <html:link action="/vistaProfesores.do?method=edicion"
> paramName="map" target="princAdmin"> Edicion de profesor
> </html:link></font></td>
> <td height="25" width="120px"><font color="#525D76"> <html:link
> action="/vistaProfesores.do?method=borra" paramName="map"
> target="princAdmin"> Borra este profesor </html:link></font></td>
> </tr>
> </table>
> </logic:iterate>
>
> in the action I retrieve the values with ...
>
> (String)request.getParameter("nombre");
> (String)request.getParameter("apellido1");
> (String)request.getParameter("apellido2");
>
> What am I doing wrong?
>
> PD: is there another possibility rather than use a map to pass
> multiple
> request parameter? (and not using JSTL).
>
> Thanks a lot!!!
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org