----Original Message Follows---- From: <[EMAIL PROTECTED]> Reply-To: "Jetspeed Users List" <[email protected]> To: <[email protected]> Subject: Struts Portlet Date: Tue, 11 Oct 2005 18:18:20 -0000 (GMT) I have a struts portlet that adds records to an Oracle database via Hibernate, this works fine. However, when I press the submit button the record is added but the page refreshes within the entire window, not within the portlet. I've taken a look through the Struts MailReader demo but can't see whe I am going wrong. The following is the struts-config.xml and jsp page, any assistance would be greatly appreciated. <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <!-- This is a blank Struts configuration file with an example welcome action/page and other commented sample elements. Tiles and the Struts Validator are configured using the factory defaults and are ready-to-use. NOTE: If you have a generator tool to create the corresponding Java classes for you, you could include the details in the "form-bean" declarations. Otherwise, you would only define the "form-bean" element itself, with the corresponding "name" and "type" attributes, as shown here. --> <struts-config> <!-- ============================================ Data Source Configuration --> <data-sources> <data-source type="org.apache.commons.dbcp.BasicDataSource"> <set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <set-property property="url" value="jdbc:oracle:thin:@ced11796:1521:CEDAR" /> <set-property property="username" value="jetspeed" /> <set-property property="password" value="jetspeed" /> <set-property property="maxActive" value="10" /> <set-property property="maxWait" value="5000" /> <set-property property="defaultAutoCommit" value="false" /> <set-property property="defaultReadOnly" value="false" /> <set-property property="validationQuery" value="SELECT count(*) from CEDAR_LINKS" /> </data-source> </data-sources> <!-- ================================================ Form Bean Definitions --> <form-beans> <form-bean name="addLinkForm" type="com.cedar.portlet.struts.AddLinkForm" /> </form-beans> <!-- ========================================= Global Exception Definitions --> <global-exceptions> <!-- sample exception handler <exception key="expired.password" type="app.ExpiredPasswordException" path="/changePassword.jsp"/> end sample --> </global-exceptions> <!-- =========================================== Global Forward Definitions --> <global-forwards> <!-- Default forward to "Welcome" action --> <!-- Demonstrates using index.jsp to forward --> <forward name="links" path="/links.do" redirect="true" /> </global-forwards> <!-- =========================================== Action Mapping Definitions --> <action-mappings> <action path="/links" type="org.apache.struts.actions.ForwardAction" parameter="/pages/displayLinks.jsp" /> <action path="/addLink" type="com.cedar.portlet.struts.AddLinkAction" name="addLinkForm" scope="request" validate="true" input="/pages/displayLinks.jsp"> <forward name="success" path="/links.do" /> </action> </action-mappings> <!-- ============================================= Controller Configuration --> <!-- <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" /> --> <controller pagePattern="$M$P" inputForward="true" processorClass="org.apache.portals.bridges.struts.PortletRequestProcessor" /> <!-- ======================================== Message Resources Definitions --> <message-resources parameter="com.cedar.portlet.struts.ApplicationResources"/> <!-- =============================================== Plug Ins Configuration --> <!-- ======================================================= Tiles plugin --> <!-- This plugin initialize Tiles definition factory. This later can takes some parameters explained here after. The plugin first read parameters from web.xml, thenoverload them with parameters defined here. All parameters are optional. The plugin should be declared in each struts-config file. - definitions-config: (optional) Specify configuration file names. There can be several comma separated file names (default: ?? ) - moduleAware: (optional - struts1.1) Specify if the Tiles definition factory is module aware. If true (default), there will be one factory for each Struts module. If false, there will be one common factory for all module. In this later case, it is still needed to declare one plugin per module. The factory will be initialized with parameters found in the first initialized plugin (generally the one associated with the default module). true : One factory per module. (default) false : one single shared factory for all modules - definitions-parser-validate: (optional) Specify if xml parser should validate the Tiles configuration file. true : validate. DTD should be specified in file header (default) false : no validation Paths found in Tiles definitions are relative to the main context. --> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <!-- Path to XML definition file --> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> <!-- Set Module-awareness to true --> <set-property property="moduleAware" value="true" /> </plug-in> <!-- =================================================== Validator plugin --> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" /> </plug-in> </struts-config> <!-- Copyright 2003 Edward Hand --> <%@ taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib uri="/tags/struts-html" prefix="html" %> <%@ taglib uri="/tags/struts-logic" prefix="logic" %> <%@ page import="com.cedar.portlet.hibernate.CedarLinksService" %> <%@ page import="java.util.List" %> <html:html locale="true"> <head> <title>Cedar Links</title> <html:base/> </head> <body bgcolor="white"> <h3>Cedar Links</h3> <html:errors /> <% /* * This code will generate a list of objects from the * database and place a reference to this list in the * request object. * */ List linkList = CedarLinksService.getInstance().getLinkList(); request.setAttribute("links", linkList); %> <p>List of links in <code>CEDAR_LINKS</code> table of database <code>jetspeed</code>.</p> <table border=1> <!-- This code will iterate over the list of items, creating a table row for each item. --> <logic:iterate id="element" name="links" scope="request" type="com.cedar.portlet.hibernate.CedarLinks" > <tr> <td><bean:write name="element" property="clId" /></td> <td><bean:write name="element" property="clDesc" /></td> <td><bean:write name="element" property="clTarget" /></td> <td><bean:write name="element" property="clUrl" /></td> <td><bean:write name="element" property="clRoleId" /></td> <td><bean:write name="element" property="clUserId" /></td> <td><bean:write name="element" property="clUserRoleYn" /></td> </tr> </logic:iterate> </table> <p>Sumbit to add a link:</p> <html:form action="addLink.do" method="post"> <table border=1> <tr><td>id:</td></tr> <tr><td><html:text property="clId" /></td></tr> <tr><td>Description:</td></tr> <tr><td><html:text property="clDesc" /></td></tr> <tr><td>Target:</td></tr> <tr><td><html:text property="clTarget" /></td></tr> <tr><td>url:</td></tr> <tr><td><html:text property="clUrl" /></td></tr> <tr><td>Role id:</td></tr>tr> <tr><td><html:text property="clRoleId" /></td></tr> <tr><td>User id:</td></tr> <tr><td><html:text property="clUserId" /></td></tr> <tr><td>User Role Y/N:</td></tr> <tr><td><html:text property="clUserRoleYn" /></td></tr> </table><br/> <html:submit /> </html:form> </body> </html:html> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can you show your psml file and the portlet.xml file ... I dont completely
understand when you say "page refreshes within the entire window". Do you
mean you have other portlets on the page, however when you click submit, all
the portlets disapper and this portlet takes up the entire space ?
- RE: Struts Portlet Shah Amit
- RE: Struts Portlet jonathan.hawkins
