Fórum

Struts2 JQuery portlet

Faramarz Dorani, modificado 11 Anos atrás.

Struts2 JQuery portlet

New Member Postagens: 7 Data de Entrada: 26/02/13 Postagens Recentes
Hi everyone,

This is my first post on Liferay forum because I'm new to Liferay with great enthusiasm.
I use Struts2 for portlets and also its jquery plugin.

I used this link's example : http://liferay-struts2-portlet.blogspot.com/2012/01/integrate-with-struts2-jquery-plugin.html
I could successfully create a struts2 portlet but when I use <sj:head jqueryui="true"/> in my jsp files it throws an java.lang.IllegalStateException: Not allowed in a portlet.

Point is, when I remove this line: <sj:head jqueryui="true"/> , everything is ok.


I really couldn't solve this.
Could anyone please help me???
Faramarz Dorani, modificado 11 Anos atrás.

RE: Struts2 JQuery portlet

New Member Postagens: 7 Data de Entrada: 26/02/13 Postagens Recentes
More Information to whom would like to reply my post:

Also my portlet.xml file contains:

...
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
		<init-param>
			<name>view-template</name>
			<value>/view.jsp</value>
		</init-param>
		
		<init-param>
			<name>defaultViewAction</name>
			<value>index</value>
		</init-param>
...


And web.xml :
...
     <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
	
		
	<listener>
		<listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener</listener-class>
	</listener>
	<listener>
		<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
	</listener>
    <listener>
 		<listener-class>com.liferay.portal.kernel.spring.context.PortletContextLoaderListener</listener-class>
	</listener>
	
	<welcome-file-list>
		<welcome-file>/html/view/index.jsp</welcome-file>
	</welcome-file-list>
	
	<servlet>
		<servlet-name>struts2servlet</servlet-name>
		<servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>struts2servlet</servlet-name>
		<url-pattern>*.action</url-pattern>
	</servlet-mapping>
	<servlet>
		<servlet-name>struts2Resources</servlet-name>
		<servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>struts2Resources</servlet-name>
		<url-pattern>/struts/*</url-pattern>
	</servlet-mapping>
...


and index.jsp :
...
&lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
&lt;%@ taglib prefix="sj" uri="/struts-jquery-tags"%&gt;

<sj:head jqueryui="true" />

<portlet:defineobjects />
<h2>Welcome!</h2>
...


and struts.xml :
...
<action name="index">
	<result>/html/view/index.jsp</result>
...
</action>


My problem is line 5 file index.jsp.

Any suggestion will be appreciated.
tnx.
Jakub Danek, modificado 11 Anos atrás.

RE: Struts2 JQuery portlet

New Member Mensagem: 1 Data de Entrada: 28/03/13 Postagens Recentes
I have the very same problem. In case you got it solved, I'd appretiate any feedback you can give.
thumbnail
Fuping Ma, modificado 10 Anos atrás.

RE: Struts2 JQuery portlet

New Member Mensagem: 1 Data de Entrada: 11/01/12 Postagens Recentes
well, the example you pointed to is from my blog.
The problem is caused by struts2-jquery-plugin.

The version you use may be higher then 3.3.3 which I used in my example.
I have noticed that after version 3.5.1, they changed the head.ftl in template.jquery (open the jar file)

The code used to be
&lt;#assign googlePath="http://ajax.googleapis.com/ajax/libs/jquery/${jQueryVersion}"&gt;
&lt;#assign googleUiPath="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21"&gt;


In the latest version:
&lt;#assign schema="${request.requestURL.substring(0, request.requestURL.indexOf(':'))}"&gt;

&lt;#assign googlePath="${schema}://ajax.googleapis.com/ajax/libs/jquery/${jQueryVersion}"&gt;
&lt;#assign googleUiPath="${schema}://ajax.googleapis.com/ajax/libs/jqueryui/${jQueryUIVersion}"&gt;


request.requestURL doesn't work in Liferay. Reason is that a call to getRequestURL() is not allowed in a portlet (see javadoc for org.apache.struts2.portlet.servlet.PortletServletRequest).

If you don't use SSL in your project, you can fix the problem by delete
&lt;#assign schema="${request.requestURL.substring(0, request.requestURL.indexOf(':'))}"&gt;
from head.ftl. And replace ${schema} with http.
Or change it to
&lt;#assign schema="http"&gt;


You can post your issue as a comment on my blog, and I will receive an email notification.
I found this post by checking the traffic sourcesemoticon