Reputation: 2086
Here is my view.jsp:
<portlet:actionURL name="getTravelId" var="travelIdUrl">
</portlet:actionURL>
for (Travel t : list) {
<a href="<%=travelIdUrl%>"><%=t.getId() %></a>
}
Then in the class:
@ProcessAction(name="getTravelId")
public void getSelectedTravelId(ActionRequest request, ActionResponse response){
String idTravel = request.getParameter("idTravel");
System.out.println("TRAVEL ID: " + idTravel);
}
I tried sending the parameter like:
<a href="<%=travelIdUrl%>?travelId="<%=t.getId()%>""><%=t.getId() %></a>
but not working.
Also tried putting the actionURL inside for, still not working
for (Travel t : list) {
<portlet:actionURL name="getTravelId" var="travelIdUrl">
<portlet:param name="idTravel" value="<%t.getId()%>"/>
</portlet:actionURL>
<a href="<%=travelIdUrl%>"><%=t.getId() %></a>
}
Does anyone have a solution? Thanks..
Upvotes: 2
Views: 3414
Reputation: 206
what exactly did not work in your last example? I think you are mixing Java code with HTML and tags. Try this example in your JSP:
<c:forEach var="t" items="${list}">
<portlet:actionURL name="getTravelId" var="travelIdUrl">
<portlet:param name="idTravel" value="${t.id}"/>
</portlet:actionURL>
<a href="${travelIdUrl}">${t.id}</a>
</c:forEach>
It creates an anchor for each item in list
with given id parameter. The example uses only HTML and tags and JSP expresion language for accessing variables.
Upvotes: 1
Reputation: 3077
You were definitely on the right path using the <portlet:param>
tag to add parameters to a portlet URL. Perhaps you can try using more JSTL and fewer scriptlets. Try something more like the code snippet below.
<c:forEach items='${list}' var="travel">
<portlet:actionURL name="getTravelId" var="travelIdUrl">
<portlet:param name="idTravel" value="${travel.id}"/>
</portlet:actionURL>
<a href="${travelIdUrl}">${travel.id}</a>
</c:forEach>
Upvotes: 2