954,219 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Updating functionality

I am using structs to try and get the "update" functionality working.

I have a list of items appearing in the jsp page, "viewItem.jsp" . I am getting this list from the database. At the
moment I am just displaying the item description, but item id is also available in the list.

Code for viewItem.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="form"%>


<html>
<head>
<title>List</title>
</head>
<body>

<table cellspacing="3" cellpadding="3" border="3" width="500">

	<tr>
		<td><b>Frequencies</b></td>
		<td><a href="enterFrequency.jsp">Add Frequency</a>
		</td>
	</tr>

	<c:forEach items="${requestScope.resultsList}" var="frequencyList">
		<tr>
			<td><c:out value="${frequencyList.description}" /></td>
		</tr>
	</c:forEach>

	<a href="enterItem.jsp"> <c:out
		value="${frequencyList.description}" /> </a>

</table>
</body>
</html>


Every item is clickable i.e. url, which will direct to another jsp page, "enterItem.jsp", which has
the input filed names as "description".

Code for enterItem.jsp

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

<html>
<head>
<title>Entering New Item</title>

</head>

<body>
<form:form action="/enterFrequency">
	<table>
		<tr>
			<td colspan="2"><h3>Frequency Entering<h3>
			</td>
		</tr>
		<tr>
			<td>Description:</td>
			<td><form:text property="description"/></td>
		</tr>
	</table>
	
<form:submit value ="Save"/>
</form:form>
</body>
</html>


What I am looking for is, that input field "description" in enterItem.jsp gets
populated with the item that was clicked on the "viewItem.jsp" page, so that the description
could be changed, and can be updated for that particular id.

I want to know how can I get this functionality work.

Suggestion or urls are greatly appreciated.

harbir
Newbie Poster
3 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

You can do so by passing the bean in session/request scope when you are clicking the link.

lookof2day
Junior Poster in Training
83 posts since Aug 2007
Reputation Points: 16
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You