aspose file tools*
The moose likes Struts and the fly likes struts example -output not display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts example -output not display" Watch "struts example -output not display" New topic
Author

struts example -output not display

maha lakshmi
Greenhorn

Joined: Feb 22, 2008
Posts: 7
Hi,
i am working on struts example http://www.laliluna.de/first-steps-using-struts-tutorial.html tutorial. its halfly working. ie i got booklist view but i can't view update booklit & delete.its not given any error.......
May be Action forwarding or linking error pls help me thanks in advance.

code is
/******BooklistForm.java*******************/

package com.yourcompany.struts.form;

import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;


public class BooklistForm extends ActionForm {

private static final long serialVersionUID = 1L;


private Collection books;
public Collection getBooks()
{
return books;
}

public void setBooks(Collection books)
{
this.books=books;
}

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}


public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
books = new ArrayList();
}
}
/**********end of BooklistForm.java**************************/


/*******************BookListAction.java**********************/

package com.yourcompany.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.rits.library.SimulateDB;
import com.yourcompany.struts.form.BooklistForm;


public class BookListAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
BooklistForm booklistForm = (BooklistForm) form;
// TODO Auto-generated method stub
SimulateDB simulateDB = new SimulateDB();
booklistForm.setBooks(simulateDB.getAllBooks(request.getSession()));


return mapping.findForward("showlist");

}
}
/*********************end BookListAction.java***************************/




booklist.jsp



<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>

<html>
<head>
<title>Show book list</title>
</head>
<body>
<table border="1">
<tbody>
<%-- set the header --%>
<tr>
<td>Author</td>
<td>Book name</td>
<td>Available</td>
<td> </td>
<td> </td>
</tr>
<%-- check if book exists and display message or iterate over books --%>

<logic:notEmpty name="booklistForm" property="books">
<logic:iterate name="booklistForm" property="books" id="book">
<tr>
<%-- print out the book informations --%>
<td><bean:write name="book" property="author" /></td>
<td><bean:write name="book" property="title" /></td>
<td><html:checkbox disabled="true" name="book" property="available" /></td>
<%-- print out the edit and delete link for each book --%>

<td><html:link action="bookEdit.do?do=editBook" paramName="book"
paramProperty="id" paramId="id">Edit</html:link></td>
<td><html:link action="bookEdit.do?do=deleteBook" paramName="book"
paramProperty="id" paramId="id">Delete</html:link></td>
</tr>
</logic:iterate>
</logic:notEmpty>
<%-- print out the add link --%>
<tr>
<td colspan="5"> <html:link action="/jsp/bookAdd.jsp">Add a new book</html:link> </td>
</tr>
<%-- end interate --%>
</tbody>
</table>
</body>
</html>

----------------------------
struts-config.xml



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources />
<form-beans>
<form-bean name="booklistForm" type="com.yourcompany.struts.form.BooklistForm" />
<form-bean name="bookEditForm" type="com.yourcompany.struts.form.BookEditForm" />
</form-beans>

<global-exceptions />
<global-forwards >
<forward name="welcome" path="/default.do" redirect="true" />

</global-forwards>

<action-mappings >
<action forward="/jsp/index.jsp" path="/default" unknown="true" />

<action
attribute="booklistForm"
input="/jsp/booklist.jsp"
name="booklistForm"
path="/booklist"
scope= "request"
type = "com.yourcompany.struts.action.BookListAction"
validate="false" >
<forward name="showlist" path="/jsp/booklist.jsp" />
</action>
<action
attribute="bookEditForm"
name="bookEditForm"
parameter="do"
path="/bookEdit"
scope="request"
type="com.yourcompany.struts.action.BookEditAction">
<forward name="showlist" path="/booklist.do" redirect="true" />
<forward name="showAdd" path="/jsp/bookAdd.jsp" />
<forward name="showEdit" path="/jsp/bookEdit.jsp" />
</action>

</action-mappings>

<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>
-------------------------------------


Regards,
Maha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts example -output not display