Fórum

JSON struts 2 PortletRequestAware issue with liferay

Vidya K, modificado 11 Anos atrás.

JSON struts 2 PortletRequestAware issue with liferay

New Member Postagens: 2 Data de Entrada: 11/06/12 Postagens Recentes
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 emoticon
]
Vidya K, modificado 11 Anos atrás.

RE: JSON struts 2 PortletRequestAware issue with liferay

New Member Postagens: 2 Data de Entrada: 11/06/12 Postagens Recentes
please somebody help me
thumbnail
Chirag Patadia, modificado 11 Anos atrás.

RE: JSON struts 2 PortletRequestAware issue with liferay

Junior Member Postagens: 29 Data de Entrada: 03/02/12 Postagens Recentes
Are you still facing this issue? In case you got solution can you please share it.
sri p, modificado 9 Anos atrás.

RE: JSON struts 2 PortletRequestAware issue with liferay

Junior Member Postagens: 85 Data de Entrada: 22/01/11 Postagens Recentes
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
Lukasz Wator, modificado 9 Anos atrás.

RE: JSON struts 2 PortletRequestAware issue with liferay

New Member Postagens: 4 Data de Entrada: 18/11/14 Postagens Recentes
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 emoticon

<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,