Foros de discusión
Struts actions in links
Bryancan Cantwell, modificado hace 16 años.
Struts actions in links
Junior Member Mensajes: 26 Fecha de incorporación: 19/06/06 Mensajes recientes
I have built a struts portlet that has a view and an edit mode and works fine.
Now I want to add a details action that I can click a link in view and the details action will display.
This is NOT an ext portlet it is standalone WAR deployable!!!!!!!!!!!!
Here is struts_config:
Here is tiles-def.xml:
Here is portlet.xml:
liferay-portlet.xml:
web.xml:
init.jsp:
template.jsp:
view.jsp:
detail.jsp
edit.page:
I cannot for the life of me make the link actually work and show the detail.jsp content in the poirtlet!
The view and the edit work fine...
What is wrong?
Now I want to add a details action that I can click a link in view and the details action will display.
This is NOT an ext portlet it is standalone WAR deployable!!!!!!!!!!!!
Here is struts_config:
<!--?xml version="1.0" encoding="UTF-8"?-->
<struts-config>
<action-mappings>
<action path="/tester/view" type="com.portlet.tester.action.ViewAction">
<forward name="portlet.tester.view" path="portlet.tester.view"></forward>
</action>
<action path="/tester/edit" type="com.portlet.tester.action.EditAction">
<forward name="portlet.tester.edit" path="portlet.tester.edit"></forward>
</action>
<action path="/tester/detail" type="com.portlet.tester.action.DetailAction">
<forward name="portlet.tester.detail" path="portlet.tester.detail"></forward>
</action>
</action-mappings>
<plug-in classname="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"></set-property>
<set-property property="moduleAware" value="true"></set-property>
<set-property property="definitions-parser-validate" value="true"></set-property>
</plug-in>
</struts-config>
Here is tiles-def.xml:
<!--?xml version="1.0" encoding="UTF-8"?-->
<tiles-definitions>
<definition name="portlet.TESTER" path="/html/portlet/tester/template.jsp"></definition>
<definition extends="portlet.TESTER" name="portlet.tester.view">
<put name="portlet_content" value="/portlet/tester/view.jsp"></put>
</definition>
<definition extends="portlet.TESTER" name="portlet.tester.edit">
<put name="portlet_content" value="/portlet/tester/edit.jsp"></put>
</definition>
<definition extends="portlet.TESTER" name="portlet.tester.detail">
<put name="portlet_content" value="/portlet/tester/detail.jsp" />
</definition>
</tiles-definitions>
Here is portlet.xml:
<!--?xml version="1.0" encoding="UTF-8"?-->
<portlet-app>
<portlet>
<portlet-name>TESTER</portlet-name>
<display-name>tester</display-name>
<portlet-class>org.apache.portals.bridges.struts.StrutsPortlet</portlet-class>
<init-param>
<name>ViewPage</name>
<value>/portlet_action/tester/view</value>
</init-param>
<init-param>
<name>EditPage</name>
<value>/portlet_action/tester/edit</value>
</init-param>
<init-param>
<name>ServletContextProvider</name>
<value>com.liferay.util.bridges.struts.LiferayServletContextProviderWrapper</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>edit</portlet-mode>
</supports>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
<portlet-info>
<title>tester</title>
<short-title>tester</short-title>
<keywords>tester</keywords>
</portlet-info>
</portlet>
</portlet-app>
liferay-portlet.xml:
<!--?xml version="1.0" encoding="UTF-8"?-->
<liferay-portlet-app>
<portlet>
<portlet-name>TESTER</portlet-name>
<struts-path>/tester/view</struts-path>
<use-default-template>true</use-default-template>
<portlet-url-class>com.liferay.portal.apache.bridges.struts.LiferayStrutsPortletURLImpl</portlet-url-class>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>
web.xml:
<!--?xml version="1.0" encoding="UTF-8"?-->
<web-app>
<display-name>tester</display-name>
<context-param>
<param-name>company_id</param-name>
<param-value>liferay.com</param-value>
</context-param>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>TESTER</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>org.apache.portals.bridges.struts.StrutsPortlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>PortletActionServlet</servlet-name>
<servlet-class>com.liferay.util.bridges.struts.LiferayPortletServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>TESTER</servlet-name>
<url-pattern>/TESTER/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>PortletActionServlet</servlet-name>
<url-pattern>/portlet_action/*</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>http://java.sun.com/portlet</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://struts.apache.org/tags-bean</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://portals.apache.org/bridges/struts/tags-portlet-html</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-portlet-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://struts.apache.org/tags-logic</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://struts.apache.org/tags-nested</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://struts.apache.org/tags-tiles</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
init.jsp:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://portals.apache.org/bridges/struts/tags-portlet-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Map" %>
template.jsp:
<%@ include file="/html/portlet/tester/init.jsp" %>
<tiles:useattribute id="tilesPortletContent" name="portlet_content" classname="java.lang.String" ignore="true" />
<div>
<jsp:include page="<%= \" html\" + tilesportletcontent %>" flush="true" />
</jsp:include></div>
view.jsp:
<%@ include file="/html/portlet/tester/init.jsp" %>
Hello world!
<li>
<html:link page="/detail">Link to details</html:link>
</li>
detail.jsp
<%@ include file="/html/portlet/tester/init.jsp" %>
DETAIL PAGE!
edit.page:
<%@ include file="/html/portlet/tester/init.jsp" %>
EDIT PAGE!
I cannot for the life of me make the link actually work and show the detail.jsp content in the poirtlet!
The view and the edit work fine...
What is wrong?
Jerry Niu, modificado hace 16 años.
RE: Struts actions in links
Expert Mensajes: 451 Fecha de incorporación: 21/06/06 Mensajes recientes
This is code from 4.0.X. I haven't tested it in a long time.
<html:link page="/portlet_action/basic_struts_portlet/subscribe/render">a link</html:link>
Bryancan Cantwell, modificado hace 16 años.
RE: Struts actions in links
Junior Member Mensajes: 26 Fecha de incorporación: 19/06/06 Mensajes recientes
Thx for the reply, but when I adapt this to my sample app from above, the portlet goes blank.
if I put in the wrong action to test, it does error, so I must have the link right to a point.
if I put in the wrong action to test, it does error, so I must have the link right to a point.
<html:link page="/portlet_action/tester/detail">a link</html:link>
Victor Zorin, modificado hace 16 años.
RE: Struts actions in links
Liferay Legend Mensajes: 1228 Fecha de incorporación: 14/04/08 Mensajes recientes
Try the following code.
or
<bean:define id="detailURL" value="" />
<portlet:renderurl var="detailURL" windowstate="MAXIMIZED">
<portlet:param name="_spage" value="/portlet_action/tester/detail" />
</portlet:renderurl>
<a href="<%=detailURL">View Details</a>
or
<a href="<portlet:renderURL var=" detailurl" windowstate="MAXIMIZED">
<portlet:param name="_spage" value="/portlet_action/tester/detail" />
">View Details</a>
Bryancan Cantwell, modificado hace 15 años.
RE: Struts actions in links
Junior Member Mensajes: 26 Fecha de incorporación: 19/06/06 Mensajes recientes
I've had success here in getting to my struts actions.
I have one last challenge:
When i create a url like this:
<portlet:renderURL windowState="exclusive"><portlet:param name="_spage" value="/portlet_action/mass_acknowledge/detail" /></portlet:renderURL>
the resulting page comes back wrapped with
I should see:
but really get:
is there some way to prevent this?
I have one last challenge:
When i create a url like this:
<portlet:renderURL windowState="exclusive"><portlet:param name="_spage" value="/portlet_action/mass_acknowledge/detail" /></portlet:renderURL>
the resulting page comes back wrapped with
tags
I should see:
{
page: 1,
total: 239,
rows: [
{id:'AD',cell:['AD','ANDORRA','Andorra','AND','20']},
{id:'AE',cell:['AE','UNITED ARAB EMIRATES','United Arab Emirates','ARE','784']},
{id:'AF',cell:['AF','AFGHANISTAN','Afghanistan','AFG','4']},
{id:'AG',cell:['AG','ANTIGUA AND BARBUDA','Antigua and Barbuda','ATG','28']},
{id:'AI',cell:['AI','ANGUILLA','Anguilla','AIA','660']},
{id:'AL',cell:['AL','ALBANIA','Albania','ALB','8']},
{id:'AM',cell:['AM','ARMENIA','Armenia','ARM','51']},
{id:'AN',cell:['AN','NETHERLANDS ANTILLES','Netherlands Antilles','ANT','530']},
{id:'AO',cell:['AO','ANGOLA','Angola','AGO','24']},
{id:'AQ',cell:['AQ','ANTARCTICA','Antarctica','','']},
{id:'AR',cell:['AR','ARGENTINA','Argentina','ARG','32']},
{id:'AS',cell:['AS','AMERICAN SAMOA','American Samoa','ASM','16']},
{id:'AT',cell:['AT','AUSTRIA','Austria','AUT','40']},
{id:'AU',cell:['AU','AUSTRALIA','Australia','AUS','36']},
{id:'AW',cell:['AW','ARUBA','Aruba','ABW','533']}]
}
but really get:
<div>
{
page: 1,
total: 239,
rows: [
{id:'AD',cell:['AD','ANDORRA','Andorra','AND','20']},
{id:'AE',cell:['AE','UNITED ARAB EMIRATES','United Arab Emirates','ARE','784']},
{id:'AF',cell:['AF','AFGHANISTAN','Afghanistan','AFG','4']},
{id:'AG',cell:['AG','ANTIGUA AND BARBUDA','Antigua and Barbuda','ATG','28']},
{id:'AI',cell:['AI','ANGUILLA','Anguilla','AIA','660']},
{id:'AL',cell:['AL','ALBANIA','Albania','ALB','8']},
{id:'AM',cell:['AM','ARMENIA','Armenia','ARM','51']},
{id:'AN',cell:['AN','NETHERLANDS ANTILLES','Netherlands Antilles','ANT','530']},
{id:'AO',cell:['AO','ANGOLA','Angola','AGO','24']},
{id:'AQ',cell:['AQ','ANTARCTICA','Antarctica','','']},
{id:'AR',cell:['AR','ARGENTINA','Argentina','ARG','32']},
{id:'AS',cell:['AS','AMERICAN SAMOA','American Samoa','ASM','16']},
{id:'AT',cell:['AT','AUSTRIA','Austria','AUT','40']},
{id:'AU',cell:['AU','AUSTRALIA','Australia','AUS','36']},
{id:'AW',cell:['AW','ARUBA','Aruba','ABW','533']}]
}
</div>
is there some way to prevent this?