• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JSR struts portlet NOT reloading first page - after it gets to the 2nd page

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This is my JSR struts porlet. It loads fine and displays 1st jsp and 2nd jsp.
But when I browse the other pages and click back on the tab for
my portlet, it displays the second page that was displayed earlier and not the
initial page.
I have 3 .jsps . First index.jsp forwards to firstFormPage.sjp
that has a button. When the button is clicked, a action is invoked that forwards to
pageDenied.jsp

When I click the portlet tab again, instead of displaying page with button, it
displays the second page. But, when I close the browser and open again, it displays
the initial page with button.

setting expiration-cache to 0 in portlet.xml did not help.

Is this action class problem ?

Please help
Rini





======= web.xml
<?xml version="1.0" encoding="UTF-8"?>

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>firstJSRStrutsPortlet</display-name>

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<jsp-config>

<taglib>

<taglib-uri>http://java.sun.com/portlet</taglib-uri>;

<taglib-location>/WEB-INF/tld/std-portlet.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>

<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/tld/struts-logic.tld</taglib-uri>

<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/tld/struts-html.tld</taglib-uri>

<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>

</taglib>

</jsp-config>


</web-app>

============ firstFormPage.jsp


<%@page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>

<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>



<html:form action="/firstReportForm">

<fieldset><legend><bean:message key="Title1" /></legend>

<table class="Wrap" >

<tbody>


<tr>

<bean:message key="message.message1"/>

</tr>

<tr>

<td>

<html:submit styleClass="button" property="action" value="Generate Talx File"/> <br/>

</td>

</tr>

<tr></tr>


</tbody>

</table>

</fieldset>

</html:form>


=========== index.jsp


<%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %>

<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>

<%@ page

language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"

%>


<portletAPI:init />


<logic:forward name="firstForward"></logic:forward>

=============== portlet.xml

<?xml version="1.0" encoding="UTF-8"?>

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" id="com.ibm.portal.struts.portlet.StrutsPortlet.4e3c8750f6">

<portlet>

<portlet-name>firstJSRStrutsPortlet</portlet-name>

<display-name>firstJSRStrutsPortlet</display-name>

<display-name xml:lang="en">firstJSRStrutsPortlet</display-name>

<portlet-class>com.ibm.portal.struts.portlet.StrutsPortlet</portlet-class>

<init-param>

<name>config</name>

<value>/WEB-INF/struts-config.xml</value>

</init-param>

<init-param>

<name>struts-servlet-mapping</name>

<value>*.do</value>

</init-param>

<init-param>

<name>WelcomeFileSearchPath</name>

<value>mode, markupName</value>

</init-param>

<init-param>

<name>ModuleSearchPath</name>

<value>markupName, mode, locale</value>

</init-param>

<init-param>

<name>IncludesSearchPath</name>

<value>manufacturer, model, version</value>

</init-param>

<init-param>

<name>EditModeLabel</name>

<value>edit</value>

</init-param>

<init-param>

<name>ConfigureModeLabel</name>

<value>configure</value>

</init-param>

<init-param>

<name>HelpModeLabel</name>

<value>help</value>

</init-param>

<init-param>

<name>ViewModeLabel</name>

<value>view</value>

</init-param>

<init-param>

<name>wps.markup</name>

<value>html</value>

</init-param>

<expiration-cache>0</expiration-cache>

<supports>

<mime-type>text/html</mime-type>

<portlet-mode>view</portlet-mode>

</supports>

<supported-locale>en</supported-locale>

<resource-bundle>portal.nl.firstJSRStrutsPortletPortletResource</resource-bundle>

<portlet-info>

<title>firstJSRStrutsPortlet</title>

<short-title>firstJSRStrutsPortlet</short-title>

<keywords>firstJSRStrutsPortlet</keywords>

</portlet-info>

<portlet-preferences>

<preference>

<name>com.ibm.struts.portal.page.view.html</name>

<value>index.jsp</value>

</preference>

</portlet-preferences>

</portlet>

</portlet-app>

================ struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>


<!-- Data Sources -->

<data-sources>

</data-sources>


<!-- Form Beans -->

<form-beans>

<form-bean name="firstReportForm" type="portal.dts.firstJSRStrutsPortlet.forms.firstReportForm"/>

</form-beans>


<!-- Global Exceptions -->

<global-exceptions>

</global-exceptions>


<!-- Global Forwards -->

<global-forwards>

<forward name="firstForward" path="/firstFormPage.jsp"/>

<!-- forward name="firstReportForm" path="/firstReportForm.do" /-->

</global-forwards>


<!-- Action Mappings -->

<action-mappings>

<!-- 2nd page- This is after the user clicks the button to start the file merge -->

<action name="firstReportForm"

path="/firstReportForm"

type="portal.firstJSRStrutsPortlet.actions.firstReportFormAction"

scope="request">

<forward redirect="false" name="success" path="/pageDenied.jsp"><!--TODO chnage-->

</forward>

<forward redirect="false" name="failure" path="/pageDenied.jsp">

</forward>

</action>

</action-mappings>

<!--Controller-->

<controller processorClass="com.ibm.portal.struts.portlet.WpRequestProcessor">

</controller>




<!-- Message Resources -->

<message-resources parameter="portal.firstJSRStrutsPortlet.resources.ApplicationResources"/>


</struts-config>


====== pageDenied.jsp

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>

<fieldset>
<table class="Wrap" >
<tbody>
<tr>
<td>
<bean:message key="message.result"/>
</td>
</tr>
</tbody>
</table>
</fieldset>

======= Action class
public class FirstFormPageAction extends StrutsAction

{

public ActionForward execute(ActionMapping mapping, ActionForm form, PortletRequest request, PortletResponse response)
throws Exception {

ActionForward forward = new ActionForward(); // return value

forward = mapping.findForward("failure");
return (forward);

}
}

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

By default the pages are picked from cache and not directed from the initial action on subsequent clicks.

Add the following line at the end of the JSP pages , if you want to follow the same execution pattern everytime.

<% WpsStrutsUtil.removeCommand(renderRequest,renderResponse,"view"); %>

To use that you ahve to import the package like this :
<%@page import="com.ibm.wps.standard.struts.util.WpsStrutsUtil"%>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic