掲示板
JSON struts 2 PortletRequestAware issue with liferay
11年前 に Vidya K によって更新されました。
JSON struts 2 PortletRequestAware issue with liferay
New Member 投稿: 2 参加年月日: 12/06/11 最新の投稿
Hi.
I am using struts 2 with liferay. i need to return some values from action class as json using getjson method
<package name="view" extends="struts-portlet-default,json-default">
i am writing this in struts.xml
My action class implements PortletRequestAware.
setPortletRequest method is not getting called if i am using <result type-json> in struts.xml
Please help me to find a solution.
my action class is like this
public class Example extends ActionSupport implements PortletRequestAware{
private String message;
private PortletRequest portletRequest;
private PortletSession session;
private String applicationScopeAttribute;
public void setPortletRequest(javax.portlet.PortletRequest portletRequest) {
session = portletRequest.getPortletSession(true);
System.out.println("session in set of feature"+session);
applicationScopeAttribute = (String)session.getAttribute("name", PortletSession.APPLICATION_SCOPE);
this.portletRequest = portletRequest;
}
public String execute()
{
return "SUCCESS";
}
public String getMessage() {
return message;
}
}
struts.xml
<package name="view" extends="struts-portlet-default,json-default">
<action name="indexeg"
class="com.opensymphony.xwork2.ActionSupport">
<result name="success">/index.jsp</result>
</action>
<action name="Example" class="com.wipro.comet.WS.Example">
<result name="SUCCESS" type="json">
</result>
</action>
</package>
</struts>
in the jsp
<script type="text/javascript">
$(document).ready(function() {
$.getJSON("/sampleportlet-portlet/Example.action", function(data) {
$.each(data, function(i, field) {
alert(i+"player i")
alert(field+"player filed");
});
});
});
</script>
please give me solution. both getJson and setPortletRequest should work ]
I am using struts 2 with liferay. i need to return some values from action class as json using getjson method
<package name="view" extends="struts-portlet-default,json-default">
i am writing this in struts.xml
My action class implements PortletRequestAware.
setPortletRequest method is not getting called if i am using <result type-json> in struts.xml
Please help me to find a solution.
my action class is like this
public class Example extends ActionSupport implements PortletRequestAware{
private String message;
private PortletRequest portletRequest;
private PortletSession session;
private String applicationScopeAttribute;
public void setPortletRequest(javax.portlet.PortletRequest portletRequest) {
session = portletRequest.getPortletSession(true);
System.out.println("session in set of feature"+session);
applicationScopeAttribute = (String)session.getAttribute("name", PortletSession.APPLICATION_SCOPE);
this.portletRequest = portletRequest;
}
public String execute()
{
return "SUCCESS";
}
public String getMessage() {
return message;
}
}
struts.xml
<package name="view" extends="struts-portlet-default,json-default">
<action name="indexeg"
class="com.opensymphony.xwork2.ActionSupport">
<result name="success">/index.jsp</result>
</action>
<action name="Example" class="com.wipro.comet.WS.Example">
<result name="SUCCESS" type="json">
</result>
</action>
</package>
</struts>
in the jsp
<script type="text/javascript">
$(document).ready(function() {
$.getJSON("/sampleportlet-portlet/Example.action", function(data) {
$.each(data, function(i, field) {
alert(i+"player i")
alert(field+"player filed");
});
});
});
</script>
please give me solution. both getJson and setPortletRequest should work ]
11年前 に Vidya K によって更新されました。
RE: JSON struts 2 PortletRequestAware issue with liferay
New Member 投稿: 2 参加年月日: 12/06/11 最新の投稿
please somebody help me
11年前 に Chirag Patadia によって更新されました。
RE: JSON struts 2 PortletRequestAware issue with liferay
Junior Member 投稿: 29 参加年月日: 12/02/03 最新の投稿
Are you still facing this issue? In case you got solution can you please share it.
9年前 に sri p によって更新されました。
RE: JSON struts 2 PortletRequestAware issue with liferay
Junior Member 投稿: 85 参加年月日: 11/01/22 最新の投稿
Hello ALL,
Anybody has solution for the above problem, I am facing the same issue.
Could you please share it, if anyone has the solution.
Thank you,
Sri
Anybody has solution for the above problem, I am facing the same issue.
Could you please share it, if anyone has the solution.
Thank you,
Sri
9年前 に Lukasz Wator によって更新されました。
RE: JSON struts 2 PortletRequestAware issue with liferay
New Member 投稿: 4 参加年月日: 14/11/18 最新の投稿
I have some issue with PortletPreferencesAware method setPortletPreferences was not called.
I solve this in a following way. In struts.xml I add portletAware interceptor and than I add this before and after defaultStack (all other default interceptors)
It work fine, but I am not 100% sure why
Try this in your issue,
I solve this in a following way. In struts.xml I add portletAware interceptor and than I add this before and after defaultStack (all other default interceptors)
It work fine, but I am not 100% sure why
<interceptors>
<interceptor name="portletAware" class="org.apache.struts2.portlet.interceptor.PortletAwareInterceptor" />
<interceptor-stack name="portletDefaultStack">
<interceptor-ref name="portletAware" />
<interceptor-ref name="defaultStack" />
<interceptor-ref name="portletAware" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="portletDefaultStack" />
Try this in your issue,