Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Jyoti RS
request.getParameter("id") is not working
December 5, 2012 4:41 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

i m very new for liferay if any 1 knows solution pls help me out of this following problems emoticon

Need to capture value of combo box so using
string abc = request.getParameter("id");
but its not working
how can i do this ?

and after running on tomcat server
if i need to print value from backing bean methods in console wat needs be done ?
bcoz after running liferay or after reloading the page nothing is displaying in console emoticon
Jan Geißler
RE: request.getParameter("id") is not working
December 5, 2012 4:59 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

Try:
long longValue = ParamUtil.getLong(portletRequest, param);
for One Long value (I suppose your ID is a long )
OR
long[] longArray = ParamUtil.getLongValues(portletRequest, param);
If it's a multi Select.
Take a look in ParamUtil. It offers lots of methods for retrieving Parameters from Request.

Hope this helps.
Jitendra Rajput
RE: request.getParameter("id") is not working
December 5, 2012 5:16 AM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 608

Join Date: January 7, 2011

Recent Posts

Are you using enctype="multipart/form-data" in your <form> tag . If yes then you can retrieve form parameters using uploadRequest.

1UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
2long longValue = ParamUtil.getLong(uploadRequest , param);
Jyoti RS
RE: request.getParameter("id") is not working
December 6, 2012 3:36 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

Thanks for reply

but still its not retrieving emoticon
Jan Geißler
RE: request.getParameter("id") is not working
December 6, 2012 3:41 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

Maybe it would be good to have some more information.

You are trying to retrieve the value in your action Method, right?
You have a form where the Value gets subbmitted, right?
The form has an action provided, right?
The form sends it values via POST, right?

Could you please show us the relevant Code snippets?

All in all it's a little less Information you provide to actually help you.
Jyoti RS
RE: request.getParameter("id") is not working
December 6, 2012 3:55 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

yeah following is my backing bean method

public void filterImage(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {

System.out.println("method called:");
String categories = ParamUtil.getString(actionRequest, "categories");

System.out.println("You selected:" + categories);

try {
RsStudent = DatabaseStatement.executeQuery("select image_path,image_name,design_group_name from design_image di,design d,design_group dg where di.design_number_ref=d.id_design and d.design_group=dg.idproduct and d.record_status='False' and dg.design_group_name='"+categories+"'");
while(RsStudent.next()) {
String path=actionRequest.getContextPath()+"/html/categories"+RsStudent.getString(1)+"/"+RsStudent.getString(2);
setImage(path);

}

}

catch(Exception ex){
System.out.println("error :"+ex);
}
}


where "categories" is the id of combo box

and following is ma jsp code

<%
PortletURL updateimageURL = renderResponse.createActionURL();
updateimageURL.setParameter(
ActionRequest.ACTION_NAME, "filterImage"
);
%>

and this form

<form name="image" method="POST" action="<%= updateimageURL.toString() %>">
Jan Geißler
RE: request.getParameter("id") is not working
December 6, 2012 4:21 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

<input> of the form?
Jyoti RS
RE: request.getParameter("id") is not working
December 6, 2012 4:48 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

<select name="categories" id="categories" >

<option value="-1">Select</option>

<option value="1">men</option>
<option value="2">women</option>
<option value="3">Accessories</option>


</select>
on changing select option the output should display
Jan Geißler
RE: request.getParameter("id") is not working
December 6, 2012 4:55 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

You mean immediatly after the change of the Selectionbox?
That would only work via JavaScript/Ajax.
To call your action Method, you need to submit the form.
Jyoti RS
RE: request.getParameter("id") is not working
December 6, 2012 5:35 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

Yup
on changing it should work and i am not submitting form
Jan Geißler
RE: request.getParameter("id") is not working
December 6, 2012 5:38 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

So you need to create the corresponding JavaScript and WebServices.
Jyoti RS
RE: request.getParameter("id") is not working
December 6, 2012 5:39 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

yeah i'll do that
Thank u emoticon
Jyoti RS
RE: request.getParameter("id") is not working
December 6, 2012 5:43 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

one more thing if i need to call the backing bean to do some action in front end
if u know will u suggest me how to do or some websites or tutorials where i can get solutions for ma probs

Thank U emoticon
Jan Geißler
RE: request.getParameter("id") is not working
December 6, 2012 5:52 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

This will be not possible, as JavaScript is client Side code, and the Backing bean will live on the Server Side, along with all the JavaCode. If you need some Cheks or Operations you would need to create a Webservice for that, which you would have to call via Ajax.
Jyoti RS
RE: request.getParameter("id") is not working
December 7, 2012 4:30 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

Hi jan

Will u pls suggest any example code or site for onchange ajax call


Thank you emoticon
Jan Geißler
RE: request.getParameter("id") is not working
December 7, 2012 4:40 AM
Answer

Jan Geißler

Rank: Expert

Posts: 354

Join Date: July 5, 2011

Recent Posts

To be honest, you have to manage some technologies to get this working, but for start learn bout Liferay and WebServices, and then maybe try and use JQuery for your Ajax implementation. As it's a quite complex subject, you should start with google and try to get a basic understanding. If you have that, try it on your own, because otherwise there will be no learning effect.
Jyoti RS
RE: request.getParameter("id") is not working
December 7, 2012 4:57 AM
Answer

Jyoti RS

Rank: New Member

Posts: 14

Join Date: November 21, 2012

Recent Posts

Yeah Thank u