留言板
Ajax call in hook jsp
Hi All,
I have a web content in which I have 2 dynamic dropdowns. Dynamic in the sense, I am listing values in those dropdowns on the basis of web contents created. Now I want to make ajax call such that the second drop down values populates on the basis of change in first drop down.
Is it possible to achieved from hook jsp?
Please reply if any of you have customized web content in such a way.
Thanks & Regards,
Raja
I have a web content in which I have 2 dynamic dropdowns. Dynamic in the sense, I am listing values in those dropdowns on the basis of web contents created. Now I want to make ajax call such that the second drop down values populates on the basis of change in first drop down.
Is it possible to achieved from hook jsp?
Please reply if any of you have customized web content in such a way.
Thanks & Regards,
Raja
Use AUI-Script
AUI().use('aui-io-request', function(A){
});
and receive your data from on Success function
AUI().use('aui-io-request', function(A){
});
and receive your data from on Success function
Harsh Joshi:
Use AUI-Script
AUI().use('aui-io-request', function(A){
});
and receive your data from on Success function
Have you tried this on hook plugin's jsp page?
I have. A hook JSP and a regular JSP are no different. Especially when you consider the fact that your hook jsp simply replaces the existing one.
Andew Jardine:
I have. A hook JSP and a regular JSP are no different. Especially when you consider the fact that your hook jsp simply replaces the existing one.
But if I say that I don't have a possibility to call serve resource method then still is it possible?
Do you have an action method that you can call?
The serveResource method is the best because there is no RENDER_PHASE that follows its completion. If you can't change the portlet source to include one, and you can't override the portlet class (if you can, then you could extend it and simply add the serveResource method) but there is an action method, yo ucan use the same approach but with a portlet actionURL. The downside is that, although it will be invoked using AJAX, at the end of the ACTION_PHASE you will move into the RENDER_PHASE (needlesssly) and run through it with no actual result coming to the front end.
The serveResource method is the best because there is no RENDER_PHASE that follows its completion. If you can't change the portlet source to include one, and you can't override the portlet class (if you can, then you could extend it and simply add the serveResource method) but there is an action method, yo ucan use the same approach but with a portlet actionURL. The downside is that, although it will be invoked using AJAX, at the end of the ACTION_PHASE you will move into the RENDER_PHASE (needlesssly) and run through it with no actual result coming to the front end.
Hi Andew,
I guess you didn't get. I said that I don't have a serve resource method. I know that its the best and very easy to do ajax functionality via serveResource(). Is there any other option is I don't have serveResource()?
Thanks,
Raja
I guess you didn't get. I said that I don't have a serve resource method. I know that its the best and very easy to do ajax functionality via serveResource(). Is there any other option is I don't have serveResource()?
Thanks,
Raja
Raja, If you dont have an option to use ext, Create a new portlet, add your desired serveResource(), call that portlet using ajax.. should work just fine.
Put the portlet at some place. Dont put anything in the view of portlet. Hide borders.
Put the portlet at some place. Dont put anything in the view of portlet. Hide borders.
Ravi Kumar Gupta:
If you dont have an option to use ext, Create a new portlet, add your desired serveResource(), call that portlet using ajax.. should work just fine.
Put the portlet at some place. Dont put anything in the view of portlet. Hide borders.
Hi Ravi,
My question is, is there any other approach in Liferay instead of serveResource() method to achieve ajax functionality? Because I need to call from some hook jsp and I don't have action class to call.
Regards,
Raja
Two options.. Call processAction with window state Exclusive. and serveResource.
Again same thing I am repeating. I don't have a action class. Which means I cannot call processAction() or serveResource().
I understand.
You do not have a class which you can modify to add a processAction() or serveResource(). In this case, you have these options -
1. Check if what you desired is exposed through json web services (Doubt it, though). If yes, call using ajax.
2. Create your own portlet, create a serveResource(), perform whatever you need, call liferay APIs, service classes etc and get the desired data. In this case, if you're not willing to show your portlet on front, then hide the borders of your portlet and keep the UI blank. This portlet will just serve you the ajax request.
Hope this helps..
You do not have a class which you can modify to add a processAction() or serveResource(). In this case, you have these options -
1. Check if what you desired is exposed through json web services (Doubt it, though). If yes, call using ajax.
2. Create your own portlet, create a serveResource(), perform whatever you need, call liferay APIs, service classes etc and get the desired data. In this case, if you're not willing to show your portlet on front, then hide the borders of your portlet and keep the UI blank. This portlet will just serve you the ajax request.
Hope this helps..
Hi Ravi,
Thanks for your suggestion. But it didn't solved my problem. I have to create a map and handling it through jQuery.
Regards,
Raja
Thanks for your suggestion. But it didn't solved my problem. I have to create a map and handling it through jQuery.
Regards,
Raja
What Kind of Map did you create? I did not understand. Would you be able to share the code?
I suspect that he doe not understand how this stuff works. A "map" sounds to me like there is no server side call being made at all and that instead everything is client side. Perhaps using the storage mechanisms offered by HTML5.
Hi Ravi & Andrew,
Sorry for late reply. The thing which I wanted from server side was not achievable through the way Liferay serveResource() method work. Andrew you are correct, I have to fetch the result on the time of page load and onchange I have to write the stuff to get through js. This was the only solution I was left with
Regards,
Raja
Sorry for late reply. The thing which I wanted from server side was not achievable through the way Liferay serveResource() method work. Andrew you are correct, I have to fetch the result on the time of page load and onchange I have to write the stuff to get through js. This was the only solution I was left with
Regards,
Raja
Hi Raja,
I have same requirement. Could you please help me how you are achieving this.
Thanks.
I have same requirement. Could you please help me how you are achieving this.
Thanks.
Nagaraju Uppalapati:
Hi Raja,
I have same requirement. Could you please help me how you are achieving this.
Thanks.
Hi Nagaraju,
Please check first that is it possible through the serveResource() method, as mentioned by Ravi and Andrew because serveResource is preferred approach. If it's not possible through ajax, than you can write your java code in the same jsp and in the javascript you and take that variable(which can be map or list) and on change event you can achieve it.
Regards,
Raja
Hi Raja,
Thanks for your reply.
Here i am developing drop downs in webcontent Structure. How to call hook jsp when i am selecting dropdown value in structure.
Any suggestion regarding this will be very helpful.
Thanks
Thanks for your reply.
Here i am developing drop downs in webcontent Structure. How to call hook jsp when i am selecting dropdown value in structure.
Any suggestion regarding this will be very helpful.
Thanks
Hi Nagaraju,
One approach is you can hook journal/article/content.jsp. At the time of rendering with the help of js, fetch the object with the id(this id you can get with the combination of portet-id and structure field name you have mentioned in structure). Here you can populate your new values after removing the old values. Also make sure of the selected value.
HTH!!!
Regards,
Raja
One approach is you can hook journal/article/content.jsp. At the time of rendering with the help of js, fetch the object with the id(this id you can get with the combination of portet-id and structure field name you have mentioned in structure). Here you can populate your new values after removing the old values. Also make sure of the selected value.
HTH!!!
Regards,
Raja
Raja Seth:
Hi Nagaraju,
One approach is you can hook journal/article/content.jsp. At the time of rendering with the help of js, fetch the object with the id(this id you can get with the combination of portet-id and structure field name you have mentioned in structure). Here you can populate your new values after removing the old values. Also make sure of the selected value.
HTH!!!
Regards,
Raja
Hi Raja,
Thanks for your reply it is very useful.
When i am override content.jsp, It is executing at the time of editing web content article and it is not executing when we edit/create Structure.But my requirement is in structure with in two dropdowns , based on selected value from first dropdown, second dropdown values should auto populate.So in this case shall i override edit_Structure.jsp ? please suggest me. If possible sample Code will be more helpful to achive this functionality.
Regards,
Nagaraju