留言板

Ajax call in hook jsp

thumbnail
Raja Seth,修改在8 年前。

Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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
Harsh Joshi,修改在8 年前。

RE: Ajax call in hook jsp

Junior Member 帖子: 27 加入日期: 15-1-28 最近的帖子
Use AUI-Script
AUI().use('aui-io-request', function(A){
});

and receive your data from on Success function
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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?
thumbnail
Andew Jardine,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 2416 加入日期: 10-12-22 最近的帖子
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.
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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?
thumbnail
Andew Jardine,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 2416 加入日期: 10-12-22 最近的帖子
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.
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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
thumbnail
Ravi Kumar Gupta,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
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.
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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
thumbnail
Ravi Kumar Gupta,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
Two options.. Call processAction with window state Exclusive. and serveResource.
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
Again same thing I am repeating. I don't have a action class. Which means I cannot call processAction() or serveResource().
thumbnail
Ravi Kumar Gupta,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
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..
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp (答复)

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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
thumbnail
Ravi Kumar Gupta,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
What Kind of Map did you create? I did not understand. Would you be able to share the code?
thumbnail
Andew Jardine,修改在8 年前。

RE: Ajax call in hook jsp

Liferay Legend 帖子: 2416 加入日期: 10-12-22 最近的帖子
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.
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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 emoticon

Regards,
Raja
Nagaraju Uppalapati,修改在8 年前。

RE: Ajax call in hook jsp

New Member 帖子: 24 加入日期: 15-6-29 最近的帖子
Hi Raja,

I have same requirement. Could you please help me how you are achieving this.


Thanks.
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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
Nagaraju Uppalapati,修改在8 年前。

RE: Ajax call in hook jsp

New Member 帖子: 24 加入日期: 15-6-29 最近的帖子
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
thumbnail
Raja Seth,修改在8 年前。

RE: Ajax call in hook jsp

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
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
Nagaraju Uppalapati,修改在8 年前。

RE: Ajax call in hook jsp

New Member 帖子: 24 加入日期: 15-6-29 最近的帖子
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