Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Mk Sin
Ajax on drop down list jsp
July 25, 2012 1:36 AM
Answer

Mk Sin

Rank: Junior Member

Posts: 74

Join Date: May 25, 2012

Recent Posts

I know this is impossible to pass parameter from javascript to scriptlet code in jsp page So I want to use ajax to post my selected value to server and then get it in scriptlet code by request object I use

 1<aui:select label="My Selection" name="ms" id="ms" onchange="<%= updateItem()%>" >
 2    <%
 3    for(String item : itemList){            
 4    %>
 5    <aui:option selected="<%= item.equals(selItem) %>" value="<%=item%>"><%=item%></aui:option>         
 6    <%}%>
 7</aui:select>
 8
 9<%!
10private Object updateItem() throws Exception{
11    //to do something with selected value
12return null;
13}%>

Please show me how to excute ajax post in this tag, or any tag can be used in my scenario
Priyanka Dhingra
RE: Ajax on drop down list jsp
July 25, 2012 1:44 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

Hi,
for the ajax call you can refer to the following link
http://michi-path.blogspot.in/2012/07/three-dynamic-dropdowns-in-liferay.html
Mk Sin
RE: Ajax on drop down list jsp
July 25, 2012 2:15 AM
Answer

Mk Sin

Rank: Junior Member

Posts: 74

Join Date: May 25, 2012

Recent Posts

emoticon cant be so difficult, in jsf2.0 i just use <h:selectonemenu> and <f:ajax>
What i realy want is just simple, get selected value from drop down list in scriptlet code
Pinkesh Gandhi
RE: Ajax on drop down list jsp
July 25, 2012 2:30 AM
Answer

Pinkesh Gandhi

Rank: Regular Member

Posts: 100

Join Date: January 26, 2012

Recent Posts

Hi MK,

I don't think so it is possible without refreshing your page.
Because all scriptlet code written on jsp is compiled and executed at server side and on other side javascript is executed at client side.
So it is not possible to assign value of javascript variable to java variable in scriptlet.

I hope it might clears your query.
Mk Sin
RE: Ajax on drop down list jsp
July 25, 2012 2:43 AM
Answer

Mk Sin

Rank: Junior Member

Posts: 74

Join Date: May 25, 2012

Recent Posts

emoticon I think if i can use ajax post to set variable to request object and get it in scriptlet .... is it impossible too emoticon
Pinkesh Gandhi
RE: Ajax on drop down list jsp
July 25, 2012 3:18 AM
Answer

Pinkesh Gandhi

Rank: Regular Member

Posts: 100

Join Date: January 26, 2012

Recent Posts

Yes bro, you can definitely set it into request attribute by ajax post but my point is how will you get it in scriptlet in jsp on ajax call completion?

Please share with us if you will find any solution for this problem.

And I suggest you please go through the web application life cycle, it may helps you.

Best Luck emoticon
Mk Sin
RE: Ajax on drop down list jsp
July 25, 2012 3:43 AM
Answer

Mk Sin

Rank: Junior Member

Posts: 74

Join Date: May 25, 2012

Recent Posts

i think if ajax can render part of page which contains scriptlet it can work emoticon arrr, i realized how impossible it is emoticon
Mk Sin
RE: Ajax on drop down list jsp
July 25, 2012 3:45 AM
Answer

Mk Sin

Rank: Junior Member

Posts: 74

Join Date: May 25, 2012

Recent Posts

i must change database from jsp page, can not use backing bean, i dont think javascript can do it, i need some serviceutil
Pinkesh Gandhi
RE: Ajax on drop down list jsp
July 25, 2012 3:47 AM
Answer

Pinkesh Gandhi

Rank: Regular Member

Posts: 100

Join Date: January 26, 2012

Recent Posts

Ok forget it.
By d way if you can tell me your exact requirement then we can find some probable solution for that.
Mk Sin
RE: Ajax on drop down list jsp
July 25, 2012 6:00 PM
Answer

Mk Sin

Rank: Junior Member

Posts: 74

Join Date: May 25, 2012

Recent Posts

hmm, i must update an expando value of webcontent when approve it(value selected by user on the same panel with comment) , but I dont know what action i can hook to do that, however, I cant do any hook right now, i think i must suppend my issue

Acctually, if it is impossible, If I just can force the lasted user who approve webcontent must to change or update expando my issue can be resovle too