A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Frameworks
»
Struts
Author
problem in tiles application
abheeshek reddy
Ranch Hand
Joined: Nov 28, 2008
Posts: 39
posted
Sep 22, 2010 15:24:35
0
hi all,
i am trying to develop a small tiles application.
here is my leftnavigation.jsp
i am getting problem only when i add below underlined code in my jsp.
. I am surprised, Nothing is displayed in my browser if add the underlined piece code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <script type="text/javascript"> function jsfunction(){ var i = document.getElementById.res.value; alert("value of i"+i); } </script> <table > <tr> <td ></td></tr> <tr> <html:html locale="true"> <html:base/> <logic:present name="TopicListForm" property="results"> <bean:size id="size" name="TopicListForm" property="results"/> <logic:equal name="size" value="0"> <center><FONT color="red"><b>There are no Topics ask administrator to add Topics</b></FONT> </center> </logic:equal> <logic:greaterThan name="size" value="0"> <table border="1"> <logic:iterate id="result" name="TopicListForm" property="results"> <tr>This is an test</tr> <tr> <td> [u]<html:link action="QList.do?method=topics" paramName="result" paramId="selected"><bean:write name="result"/></html:link>[/u] </td> </tr> </logic:iterate> </table> </logic:greaterThan> <tr>This is another test</tr> </logic:present> </html:html></tr> <tr> <td ></td></tr> </table>
Below is
struts
config file
<?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/> <form-beans> <form-bean name="dataForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="eid" type="java.lang.String"/> <form-property name="name" type="java.lang.String"/> <form-property name="address" type="java.lang.String"/> </form-bean> <form-bean name="delForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="eid" type="java.lang.String"/> </form-bean> <form-bean name="TopicListForm" type="roseindia.web.struts.form.TopicListForm"> </form-bean> </form-beans> <global-exceptions/> <!-- =========================================== Global Forward Definitions --> <global-forwards> <!-- Default forward to "Welcome" action --> <!-- Demonstrates using index.jsp to forward --> <forward name="welcome" path="/Welcome.do"/> <forward name="getActions" path="/getAction.do"/> </global-forwards> <action-mappings> <action path="/mytiles" forward="MyTiles"/> <action path="/insert" forward="insertTile"/> <action path="/update" forward="updateTile" /> <action path="/delete" forward="deleteTile"/> <action path="/updatedata" name="dataForm" type="updateAction" scope="session"> <forward name="success" path="tile.main.success" redirect="false"/> <forward name="failure" path="tile.main.failure" redirect="false"/> </action> <action path="/insertdata" name="dataForm" type="insertAction" scope="session"> <forward name="success" path="tile.main.success" redirect="false"/> <forward name="failure" path="tile.main.failure" redirect="false"/> </action> <action path="/deletedata" name="delForm" type="delAction" scope="session"> <forward name="success" path="tile.main.success" redirect="false"/> <forward name="failure" path="tile.main.failure" redirect="false"/> </action> <action path="/getAction" name="TopicListForm" scope="request" validate="true" input="/pages/Welcome.jsp" type="roseindia.web.struts.action.TopicListAction"> <forward name="success" path="/pages/home.jsp"/> </action> <action path="/QList" name="TopicListForm" scope="request" input="/pages/LeftNavigation.jsp" parameter="method" type="roseindia.web.struts.action.QListAction"> </action> <action path="/java" type="roseindia.web.struts.action.TopicListAction" name="TopicListForm" scope="request" validate="false" > <forward name="success" path="/pages/Welcome.jsp"/> <forward name="error" path="/pages/Welcome.jsp"/> </action> </action-mappings> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/> <set-property property="moduleAware" value="true"/> </plug-in> </struts-config>
Below is my action
public class QListAction extends DispatchAction{ public ActionForward topics( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ System.out.println("inside the QListAction"); TopicListForm tlForm = (TopicListForm)form; request.getParameter("selected"); System.out.println(" value of parameter "+request.getParameter("selected")); System.out.println(" value of tname "+tlForm.getSelected()); return mapping.findForward("success"); } }
below is my FormBean
import java.util.List; import org.apache.struts.action.ActionForm; public class TopicListForm extends ActionForm{ private String id; private String tname; private List results; private String selected; public String getSelected() { System.out.println(" value of inside bean selected "+selected); return selected; } public void setSelected(String selected) { this.selected = selected; System.out.println(" value of inside bean selected "+selected); } public List getResults() { return results; } public void setResults(List results) { this.results = results; } public TopicListForm() { System.out.println("inside TopicList Form"); } public TopicListForm(String id, String tname) { this.id = id; this.tname = tname; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTname() { return tname; } public void setTname(String tname) { this.tname = tname; System.out.println("inside TopicListForm and the value of tname: "+tname); } }
Below is MyTilesHome.jsp
<html> <head> <title> Search Screen </title> </head> <body> <table > <tr> <td > <tiles:insert attribute="header" /> </td> </tr> <!-- Content --> <tr> <!-- start content --> <td > <tiles:insert attribute="left-content"/> </td> <td > <tiles:insert attribute="main-content" /> </td> <!-- end content --> </tr> <tr> <td > <tiles:insert attribute="footer" /> </td> </tr> </table> </body> </html>
Below is tiles-defs.xml
<tiles-definitions> <definition name="MyTiles" path="/pages/MyTilesHome.jsp"> <put name="header" value="/pages/BaseHeader.jsp" /> <put name="left-content" value="/pages/LeftNavigation.jsp"/> <put name="main-content" value="/pages/welcome.jsp"/> <put name="footer" value="/pages/BaseFooter.jsp" /> </definition> <definition name="tile.main.success" extends="MyTiles"> <put name="main-content" value="/pages/success.jsp" /> </definition> <definition name="tile.main.failure" extends="MyTiles"> <put name="main-content" value="/pages/failure.jsp" /> </definition> <definition name="insertTile" extends="MyTiles"> <put name="main-content" value="/pages/insert.jsp" /> </definition> <definition name="deleteTile" extends="MyTiles"> <put name="main-content" value="/pages/delete.jsp" /> </definition> <definition name="updateTile" extends="MyTiles"> <put name="main-content" value="/pages/update.jsp" /> </definition> </tiles-definitions>
please help...Thanks in advance
screen shot.jpg
I agree. Here's the link:
http://aspose.com/file-tools
subject: problem in tiles application
Similar Threads
Interesting tiles/struts making a menu question
problem with tiles mapping
Problem with struts tiles
Tiles in struts?
Tiles problem - forward to other page but all frame lost
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter