Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Giuliane Monteiro
problems to get a checkbox value in action
March 17, 2011 7:21 AM
Answer

Giuliane Monteiro

Rank: New Member

Posts: 12

Join Date: March 6, 2011

Recent Posts

Hi people.

I try to get a value from checkbox in my jsp but it's not work.

I try to get the value this way.

<form
action="<liferay-portlet:actionURL name="editImageInit" />"
enctype="multipart/form-data" method="post"
name="<portlet:namespace />fm"
onSubmit="<portlet:namespace />editImageInit(); return false;">


<p><input name="imageId" type="checkbox" value="<%=igImage.getLargeImageId()%>" /> <img
src="/image/image_gallery?img_id=<%=igImage.getLargeImageId()%>"
width="100" height="100" /></p>


<%
}
}
%> <input type="submit"
value="<liferay-ui:message key="admPopUp.message.editar" />" /></form>

<aui:script>
function <portlet:namespace />editImageInit() {

for(var i=0; i< document.<portlet:namespace />fm.length; i++){

if(document.<portlet:namespace />fm.imageId.checked == true){

document.<portlet:namespace />fm.<portlet:namespace />imageId.value = document.<portlet:namespace />fm.<portlet:namespace />imageId.value;

}
}
submitForm(document.<portlet:namespace />fm);

}
</aui:script>


public void editImageInit(ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

System.out.println(" ======================ParamUtil.getLong(actionRequest, imageId) "+ParamUtil.getLong(actionRequest, "imageId"));
System.out.println(" ======================ParamUtil.getLong(actionRequest, imageId)" +ParamUtil.getString(actionRequest, "imageId"));
System.out.println("========================actionRequest.getAttribute(imageId) "+actionRequest.getAttribute("imageId"));
System.out.println("========================actionRequest.getParameter(imageId) "+actionRequest.getParameter("imageId"));
}
nghia nguyen
RE: problems to get a checkbox value in action
April 26, 2011 12:05 AM
Answer

nghia nguyen

Rank: New Member

Posts: 15

Join Date: April 24, 2011

Recent Posts

Giuliane Monteiro:
Hi people.

I try to get a value from checkbox in my jsp but it's not work.

I try to get the value this way.

<form
action="<liferay-portlet:actionURL name="editImageInit" />"
enctype="multipart/form-data" method="post"
name="<portlet:namespace />fm"
onSubmit="<portlet:namespace />editImageInit(); return false;">


<p><input name="imageId" type="checkbox" value="<%=igImage.getLargeImageId()%>" /> <img
src="/image/image_gallery?img_id=<%=igImage.getLargeImageId()%>"
width="100" height="100" /></p>


<%
}
}
%> <input type="submit"
value="<liferay-ui:message key="admPopUp.message.editar" />" /></form>

<aui:script>
function <portlet:namespace />editImageInit() {

for(var i=0; i< document.<portlet:namespace />fm.length; i++){

if(document.<portlet:namespace />fm.imageId.checked == true){

document.<portlet:namespace />fm.<portlet:namespace />imageId.value = document.<portlet:namespace />fm.<portlet:namespace />imageId.value;

}
}
submitForm(document.<portlet:namespace />fm);

}
</aui:script>


public void editImageInit(ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

System.out.println(" ======================ParamUtil.getLong(actionRequest, imageId) "+ParamUtil.getLong(actionRequest, "imageId"));
System.out.println(" ======================ParamUtil.getLong(actionRequest, imageId)" +ParamUtil.getString(actionRequest, "imageId"));
System.out.println("========================actionRequest.getAttribute(imageId) "+actionRequest.getAttribute("imageId"));
System.out.println("========================actionRequest.getParameter(imageId) "+actionRequest.getParameter("imageId"));
}


Hi I think this code make your checkbox not work
enctype="multipart/form-data"
Tejas patel
RE: problems to get a checkbox value in action
September 7, 2012 6:39 AM
Answer

Tejas patel

Rank: Junior Member

Posts: 71

Join Date: January 23, 2012

Recent Posts

nghia was right in my case also, but what is the solution for that to upload image as well as some data in action url.
if i remove enctype="multipart/form-data" , it gives errors like
"the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/x-www-form-urlencoded".
so what is the best solution for this.