You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ricardo Cortes <rc...@boltstaff.com> on 2004/05/25 17:17:01 UTC
JSTL and Multibox Submit Problem
Hi there,
I am having a problem getting the checked values from a multibox that is submitted to my action and I was hoping one of you could help me out. I followed Ted Husted's example of using a Multibox within an iteration but I have a feeling that my setup is a bit different and thus renders a different solution. I'm using a JSTL forEach loop to loop through a list of MessageInstance objects. I want the user to be able to check which MessageInstances should be deleted and the action to perform the deletion. Everything gets rendered ok but when the form is submitted, the String[] object in the form is empty. I should also note that everything works fine if I use an html:submit but when I try to use an html:link to do the submit I don't get any checked values in my String[] object. I've included some code snippets below. Any help would be awesome.
Thanks!
Ricardo
JSP:
===
Submit Link (inside ManageNotesForm):
====================================
<jsp:useBean id="deleteNotesLink" class= "java.util.HashMap"/>
<c:set target="${deleteNotesLink}" property="membername" value="${requestScope.membername}"/>
<c:set target="${deleteNotesLink}" property="task" value="delete"/>
<html:link action="/submitMain" name="deleteNotesLink">delete</html:link>
forEach Loop (inside ManageNotesForm):
=====================================
<c:forEach items="${sessionScope.messageInstances}" var="aMessageInstance" varStatus="status">
<html:multibox name="${formName}" property="selectedItems">
<c:out value="${aMessageInstance.id}"/>
</html:multibox>
<c:out value="${aMessageInstance.id}"/>
</c:forEach>
ManageNotesForm Bean:
====================
private String[] selectedItems = {};
public String[] getSelectedItems() {
return selectedItems;
}
public void setSelectedItems(String[] selectedItems) {
this.selectedItems = selectedItems;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: JSTL and Multibox Submit Problem
Posted by Richard Yee <ry...@yahoo.com>.
Ricardo,
If you are going to use the html:link tag, then you
need to have it trigger a call to a JavaScript
function that will submit the form for you. Otherwise,
jjust clicking the link will not submit the form.
Regards,
Richard
--- Ricardo Cortes <rc...@boltstaff.com> wrote:
> Hi there,
>
> I am having a problem getting the checked values
> from a multibox that is submitted to my action and I
> was hoping one of you could help me out. I followed
> Ted Husted's example of using a Multibox within an
> iteration but I have a feeling that my setup is a
> bit different and thus renders a different solution.
> I'm using a JSTL forEach loop to loop through a
> list of MessageInstance objects. I want the user to
> be able to check which MessageInstances should be
> deleted and the action to perform the deletion.
> Everything gets rendered ok but when the form is
> submitted, the String[] object in the form is empty.
> I should also note that everything works fine if I
> use an html:submit but when I try to use an
> html:link to do the submit I don't get any checked
> values in my String[] object. I've included some
> code snippets below. Any help would be awesome.
>
> Thanks!
> Ricardo
>
> JSP:
> ===
>
> Submit Link (inside ManageNotesForm):
> ====================================
>
> <jsp:useBean id="deleteNotesLink" class=
> "java.util.HashMap"/>
> <c:set target="${deleteNotesLink}"
> property="membername"
> value="${requestScope.membername}"/>
> <c:set target="${deleteNotesLink}"
> property="task" value="delete"/>
> <html:link action="/submitMain"
> name="deleteNotesLink">delete</html:link>
>
> forEach Loop (inside ManageNotesForm):
> =====================================
>
> <c:forEach
> items="${sessionScope.messageInstances}"
> var="aMessageInstance" varStatus="status">
> <html:multibox name="${formName}"
> property="selectedItems">
> <c:out value="${aMessageInstance.id}"/>
> </html:multibox>
> <c:out value="${aMessageInstance.id}"/>
> </c:forEach>
>
> ManageNotesForm Bean:
> ====================
>
> private String[] selectedItems = {};
>
> public String[] getSelectedItems() {
> return selectedItems;
> }
>
> public void setSelectedItems(String[]
> selectedItems) {
> this.selectedItems = selectedItems;
> }
>
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org