You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Martin Stahovec <st...@post.sk> on 2005/05/27 23:20:09 UTC
editing rows
Hi guys;
(one more time)
I'm new to struts and I just learn how to use it.I'm working on my first struts app and have following problem: I don't know, how to edit rows in my jsp.
On the first jsp(Form.jsp) I have just the table, taht consists of the columns ID, CURR, NAME, START and buttons DELETE and EDIT. When I click EDIT button, I want to open FormEdit.jsp with
ID-text field, CURR-listOfValue, NAME-text field, START-text field with the values from the selected row in the first jsp. At the bottom there is a SAVE button. Can anybody tell me, how can I do this........remember I'm new to struts :-) Thanks
source of Form.jsp
<script>
function doEdit(cisPdo, id) {
var url = "FormEdit.jsp";
url += "?action=UPDATE";
url += "&cisPdo=" + cisPdo+ "&id=" +id;
document.location.href=url;
}
</script>
<tr>
<td><%=Card.getId()%></td>
<td><%=Card.getCodCurr()%></td>
<td><%=Card.getName()%></td>
<td><%=Card.getStart()%></td>
<td>
<input type="button" value="Delete" onClick="doDelete(....)
<input type="button" value="Edit" onClick="doEdit('...', '<%=Card.getId()%>')">
</td>
</tr>
source of FormEdit.jsp
....
<html:form action="insertCpp">
<table>
<tr>
<td>ID:</td>
<td>CURR:</td>
<td>NAME:</td>
<td>START:</td>
</tr>
<tr>
<td><html:text property="id"/></td>
<td>
<html:select name="Form" property="codCurr">
<html:options collection="CurrBean" property="codCurr" labelProperty="nameCurr"/>
</html:select>
</td>
<td><html:text property="name"/></td>
<td><html:text property="start"/></td>
</tr>
</table>
<html:submit><bean:message key="button.cpp.save.submit"/></html:submit>
</html:form>
________
Vsetci sa raz zideme na http://blog.sme.sk
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: editing rows
Posted by Eddie Bush <ea...@swbell.net>.
Hi Martin,
The important link here is the key for your row (row.id). Establish a way
to pass that to your edit page, via a hidden field, for example, and that's
really it.
Recall (Struts 101) that we preface all pages (JSPs) with actions. ... so
your action can take the ID value that was submitted to it and lookup that
particular row, which it'll populate a form bean for and then forward to
your JSP page. Your page just lays the data out. Then, your save button
will cause an action to be invoked that will save the row to the database.
I've taken to using the LookupDispatchAction quite a bit. By doing so, I
can lower the number of classes I have running around, and also provide a
mechanism for internationalization, based on Locale. It can be cumbersome
to get your head around at first, but it's well worth the effort to learn.
If you were to do this, you could easily build a single action that would
handle your display, edit, save, delete functionality for each type of "row"
you have (one action class per "row type").
Generally, my "list" pages will generate links that, when clicked on, will
cause the edit page to "pop-up". The link is nothing but a link to my edit
action that passes along important parameters, like that ID value, and
perhaps a parameter indicating which method to invoke (if you're using the
LookupDispatchAction approach).
Is that clear as mud?
Good Luck!
Eddie
----- Original Message -----
From: "Martin Stahovec" <st...@post.sk>
To: <us...@struts.apache.org>
Sent: Friday, May 27, 2005 4:20 PM
Subject: editing rows
> Hi guys;
> (one more time)
> I'm new to struts and I just learn how to use it.I'm working on my first
> struts app and have following problem: I don't know, how to edit rows in
> my jsp.
> On the first jsp(Form.jsp) I have just the table, taht consists of the
> columns ID, CURR, NAME, START and buttons DELETE and EDIT. When I click
> EDIT button, I want to open FormEdit.jsp with
> ID-text field, CURR-listOfValue, NAME-text field, START-text field with
> the values from the selected row in the first jsp. At the bottom there is
> a SAVE button. Can anybody tell me, how can I do this........remember I'm
> new to struts :-) Thanks
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0521-4, 05/27/2005
Tested on: 5/28/2005 11:57:36 AM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org