Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Faramarz Dorani
Struts2 JQuery portlet
5 marzo 2013 1.58
Risposta

Faramarz Dorani

Punteggio: New Member

Messaggi: 7

Data di Iscrizione: 25 febbraio 2013

Messaggi recenti

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
RE: Struts2 JQuery portlet
5 marzo 2013 2.10
Risposta

Faramarz Dorani

Punteggio: New Member

Messaggi: 7

Data di Iscrizione: 25 febbraio 2013

Messaggi recenti

More Information to whom would like to reply my post:

Also my portlet.xml file contains:

 1...
 2<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
 3        <init-param>
 4            <name>view-template</name>
 5            <value>/view.jsp</value>
 6        </init-param>
 7       
 8        <init-param>
 9            <name>defaultViewAction</name>
10            <value>index</value>
11        </init-param>
12...


And web.xml :
 1...
 2     <filter>
 3        <filter-name>struts2</filter-name>
 4        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 5    </filter>
 6    <filter-mapping>
 7        <filter-name>struts2</filter-name>
 8        <url-pattern>/*</url-pattern>
 9    </filter-mapping>
10   
11       
12    <listener>
13        <listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener</listener-class>
14    </listener>
15    <listener>
16        <listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
17    </listener>
18    <listener>
19         <listener-class>com.liferay.portal.kernel.spring.context.PortletContextLoaderListener</listener-class>
20    </listener>
21   
22    <welcome-file-list>
23        <welcome-file>/html/view/index.jsp</welcome-file>
24    </welcome-file-list>
25   
26    <servlet>
27        <servlet-name>struts2servlet</servlet-name>
28        <servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
29    </servlet>
30    <servlet-mapping>
31        <servlet-name>struts2servlet</servlet-name>
32        <url-pattern>*.action</url-pattern>
33    </servlet-mapping>
34    <servlet>
35        <servlet-name>struts2Resources</servlet-name>
36        <servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
37    </servlet>
38    <servlet-mapping>
39        <servlet-name>struts2Resources</servlet-name>
40        <url-pattern>/struts/*</url-pattern>
41    </servlet-mapping>
42...


and index.jsp :
 1...
 2<%@ taglib prefix="s" uri="/struts-tags"%>
 3<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
 4
 5<sj:head jqueryui="true"/>
 6
 7<portlet:defineObjects />
 8<h2>Welcome!</h2>
 9...


and struts.xml :
1...
2<action name="index">
3    <result>/html/view/index.jsp</result>
4...
5</action>


My problem is line 5 file index.jsp.

Any suggestion will be appreciated.
tnx.
Jakub Danek
RE: Struts2 JQuery portlet
28 marzo 2013 16.41
Risposta

Jakub Danek

Punteggio: New Member

Messaggi: 1

Data di Iscrizione: 28 marzo 2013

Messaggi recenti

I have the very same problem. In case you got it solved, I'd appretiate any feedback you can give.
Fuping Ma
RE: Struts2 JQuery portlet
25 giugno 2013 23.16
Risposta

Fuping Ma

Punteggio: New Member

Messaggi: 1

Data di Iscrizione: 10 gennaio 2012

Messaggi recenti

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
1<#assign googlePath="http://ajax.googleapis.com/ajax/libs/jquery/${jQueryVersion}">
2<#assign googleUiPath="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21">


In the latest version:
1<#assign schema="${request.requestURL.substring(0, request.requestURL.indexOf(':'))}">
2
3<#assign googlePath="${schema}://ajax.googleapis.com/ajax/libs/jquery/${jQueryVersion}">
4<#assign googleUiPath="${schema}://ajax.googleapis.com/ajax/libs/jqueryui/${jQueryUIVersion}">


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
1<#assign schema="${request.requestURL.substring(0, request.requestURL.indexOf(':'))}">
from head.ftl. And replace ${schema} with http.
Or change it to
1<#assign schema="http">


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