| Author |
Struts logic:iterate + html:link
|
Remi Malessa
Greenhorn
Joined: Aug 27, 2007
Posts: 7
|
|
Hi. I spend whole night working on a piece of code. It suppose to Iterate through a bean. The Bean is ArrayList and name in the request scope is eventsList.It holds objects of EventBean. The Iteration works fine. But the problems start when I'm trying to pass a parameter "eventId", to the DispatchAction by the html:link. I don't receive the parameter (null). Here is the piece of .jsp code: . . . <logic:iterate id="event" name="eventsList" indexId="cnt"> <tr> <!-- link to the event detail --> <!-- Event time/date --> <td><bean:write name="event" property="eventStart" /></td> <!-- Event name --> <td><bean:write name="event" property="gameName" /></td> <!-- link to join the event --> <th><html:link href="EventDetails.do?command=details" paramId="Id" paramName="event" paramProperty="eventId">details</html:link></th> </tr> </logic:iterate> . . . Here is mapping for this action <action path="/EventDetails" type="uk.ac.aber.rmm03.gamescalendar.controller.EventDisplayDispatchAction" scope="request" validate="false" parameter="command"> <forward name="displayEvent" path="/WEB-INF/secured/displayevent.jsp" /> </action> And piece of code from the EventDisplayDispatchAction . . . public class EventDisplayDispatchAction extends DispatchAction { public ActionForward details(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { int gameId = 0; System.out.println("AAA" + request.getParameter("Id")); gameId = Integer.parseInt(request.getParameter("Id")); . . . It fails on "System.out.println("AAA" + request.getParameter("Id"));" And gives me: "java.lang.NumberFormatException: null java.lang.Integer.parseInt(Unknown Source) java.lang.Integer.parseInt(Unknown Source) uk.ac.aber.rmm03.gamescalendar.controller.EventDisplayDispatchAction.details(EventDisplayDispatchAction.java:32) . . ." I would much appreciate some help. Cheers
|
 |
Remi Malessa
Greenhorn
Joined: Aug 27, 2007
Posts: 7
|
|
|
I can see the result in the address field "http://192.168.0.2:8080/games-calendar-struts/EventDetails.do?command=details&Id=2" So it look like its passing the parameter . . .
|
 |
Remi Malessa
Greenhorn
Joined: Aug 27, 2007
Posts: 7
|
|
For anyone who'll come across situation like this. If you are extending DispatchAction class put redirect="false" in the action mapping . . .
|
 |
 |
|
|
subject: Struts logic:iterate + html:link
|
|
|