• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts logic:iterate + html:link

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For anyone who'll come across situation like this.
If you are extending DispatchAction class put redirect="false" in the action mapping . . .
 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic