Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Rewati Raman
how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 4:31 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

i have to pass two value from jsp to portlet class
using
<aui: input> and <aui:button>
and i want to retreive it in portlet class
as my basic requirement is to download a file as per the submited value on client side i am using resourceresponse
but i couldnt able to pass the value
i can able to pass using actionrequest but i wont able to use resourceresponse and viceversa

so pls give some suggestion im in need
David H Nebinger
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 5:11 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Resource request does not receive the parameters from forms that the action request gets.

You'll have to manually build your parameters and append them to the resource request url.
Rewati Raman
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 6:49 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

sir,

if u hava any sample for that code then it would be very great for me because im stuggling to solve that issue


how should i use resourse response with action request
so that i could retreive value using actionresponse and and give the downloading popup to jsp page using resourceresponse
David H Nebinger
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 7:07 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Two separate things. When you're within an action handler, you're not connected to a resource request.

Your page is the one that issues requests, so the page will have the urls for either the action or resource request.
Amit Doshi
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 7:25 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

Hi Rewati,

The Below is the code for making the Call for ResourceURL with Javascript

1
2<portlet:resourceURL var="SubmitURL"  />
3        <input type="text" name="txt1" id="txt1" />
4    <input   type="button" onclick="helpful();"  value="Submit" />         


On Button Click Call JavaScript Function as follows

 1
 2function helpful()
 3{
 4var textvalue=document.getElementById('txt1').value;
 5     $.ajax ({
 6       
 7        url:'<%=SubmitURL%>',
 8        type: 'POST',
 9        data : ({
10             textVal: textvalue
11            
12             }),
13         success: function()
14         {
15            alert('success');
16            
17         }
18    });
19   
20   
21}


Now on the ServeResource method you can get the value using below code

1
2final String textValue= resourceRequest.getParameter("textVal");


Your work is done now. You will get the Required Parameter using ajax.

Hope it helps.

Thanks & Regards,
Amit Doshi
Rewati Raman
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 7:33 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

thanks for response,

but is there any way that i could pass the values from jsp to filter the data and generate the file using resourseresponse
im not getting any solution for that
Rewati Raman
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 7:41 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Amit Doshi:
Hi Rewati,

The Below is the code for making the Call for ResourceURL with Javascript

1
2<portlet:resourceURL var="SubmitURL"  />
3        <input type="text" name="txt1" id="txt1" />
4    <input   type="button" onclick="helpful();"  value="Submit" />         


On Button Click Call JavaScript Function as follows

 1
 2function helpful()
 3{
 4var textvalue=document.getElementById('txt1').value;
 5     $.ajax ({
 6       
 7        url:'<%=SubmitURL%>',
 8        type: 'POST',
 9        data : ({
10             textVal: textvalue
11            
12             }),
13         success: function()
14         {
15            alert('success');
16            
17         }
18    });
19   
20   
21}


Now on the ServeResource method you can get the value using below code

1
2final String textValue= resourceRequest.getParameter("textVal");


Your work is done now. You will get the Required Parameter using ajax.

Hope it helps.

Thanks & Regards,
Amit Doshi



thanks for ur response and ill try to implement it
Amit Doshi
RE: how to pass parameter using Resourceresponse from jsp to java page
May 7, 2012 7:42 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

The code that I written above will pass the Value From jsp only.
Now what you need to do in the background, it depends on you. You can filter or Generate the file using I/O .
Pradeep Sharma
RE: how to pass parameter using Resourceresponse from jsp to java page
February 8, 2013 8:22 AM
Answer

Pradeep Sharma

Rank: Junior Member

Posts: 49

Join Date: September 6, 2011

Recent Posts

I am also looking for something similar to this problem: how to pass parameter using Resourceresponse from jsp to java page. I have also the same issue, I tried to mock the input value in JSP, It works. I am using Spring MVC portlet

<portlet:resourceURL var="JSPResourceURL">
<portlet:param name="system" value="APP" />
<portlet:param name="mngmtCo" value="NA" />
<portlet:param name="beginDate" value="01/01/2007" />
<portlet:param name="endDate" value="01/01/2013" />
</portlet:resourceURL>

5th request is in the dropdown list about kind of report, HTML / PDF / EXCEL

This works but this is just test for one set of input, Client cannot input the different record from screen. For this if any solution, Please let me know.

Thanks you in advance
Pradeep