struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Mitchell" <jmitc...@yahoo.com>
Subject RE: How to track the row id......
Date Sat, 16 Feb 2002 05:04:25 GMT
Alex, are you storing that list in the users session?  If so, how will that
impact performance.  If not, how can struts remember anything about a list
between requests?

If I am way off target here........just ignore my ramblings:-)

Not sure if this answers you question, but what I think you are asking is
"how can I properly link an id from an actionform without having to re-write
a new taglib for each new actionform type?"

I noticed from the struts-example that the demo app has a custom taglib for
linking the subscription id as it iterates over the action form beans.  I
wanted the same thing, but I didn't want to have to write a new taglib for
each new bean (CustomerActionForm, AddressActionForm).  My solution was to
create a base class that extended ActionForm and make all new ActionForms
extend that base class.

In that base class I have a method for getId() and for setId().  So with a
generic "LinkId" taglib, I am able to reuse it for every ActionForm in the
entire application.


Example code:
<table>
<logic:iterate  name="my_arraylist_of_actionforms"
id="the_current_actionform">
 <TR>
   <TD>
  <custom_taglib:linkId page="/editActionWhatever.do">
    <html:img page="/images/edit.jpg" border="0"/>
  </custom_taglib:linkId>
  </TD>
   <TD>
  <custom_taglib:linkId page="/deleteActionWhatever.do">
    <html:img page="/images/delete.jpg" border="0"/>
  </custom_taglib:linkId>
  </TD>
  <TD>
    <bean:write name="the_current_actionform" property="firstName" />
  </TD>
  <TD>
    <bean:write name="the_current_actionform" property="lastName" />
  </TD>
 </TR>
</logic:iterate>
</Table>


Will render like this:
<table>
 <TR>
  <TD><A href="/myapp/editActionWhatever.do?id=1"><img
src="/myapp/images/edit.jpg" border="0"></a></TD>
  <TD><A href="/myapp/deleteActionWhatever.do?id=1"><img
src="/myapp/images/delete.jpg" border="0"></a></TD>
  <TD>Bill</TD>
  <TD>Gates</TD>
 </TR>
 <TR>
  <TD><A href="/myapp/editActionWhatever.do?id=3"><img
src="/myapp/images/edit.jpg" border="0"></a></TD>
  <TD><A href="/myapp/deleteActionWhatever.do?id=3"><img
src="/myapp/images/delete.jpg" border="0"></a></TD>
  <TD>Ted</TD>
  <TD>Turner</TD>
 </TR>
</Table>



*Note - I actually use a Constants class to define things such as "id" so
that it isn't (really) hard-coded in my application.
Which means that the above code was modified slightly for simplicity...
<logic:iterate  name="my_arraylist_of_actionforms"
id="the_current_actionform">
is actually
<logic:iterate  name="<%=IMarketConstants.RESULT_LIST%>"
id="the_current_actionform">

and my taglib does this....
...
...
	if (page.indexOf("?") < 0)
	    url.append("?");
	else
	    url.append("&");
	url.append( IMarketConstants.ID + "=");    /<--   here it is
	url.append(ResponseUtils.filter(view.getId() + ""));
...
...


James Mitchell
Software Engineer
Open-Tools.org
Home Phone (770) 822-3359
Cell Phone: (678) 910-8017


-----Original Message-----
From: Alex Colic [mailto:Alex.Colic@pop-ware.com]
Sent: Friday, February 15, 2002 3:00 PM
To: VikashK@Gafri.com; struts-user@jakarta.apache.org
Subject: RE: How to track the row id......


Hi,

I just finished doing something similar. I have an ArrayList with a bunch of
charging objects. When the user goes to the summary screen I iterate through
all the objects and show them the data. I have added two icons, edit and
delete at the end of each charging row. Each of these icons is a link e.g.:

<html:link page="/editCharging.do" indexed="true">

When the user clicks on the edit icon my editChargingAction is called with a
request parameter of 'indexed'. This holds the element in the ArrayList that
the user wants to edit. I take that index, get the details for that charge,
put that object into request session and send them back to the same page. I
have a form on that page that looks for that object and shows the details.

Is this making any sense? Is this what you were looking for?

Alex

-----Original Message-----
From: VikashK@Gafri.com [mailto:VikashK@Gafri.com]
Sent: February 15, 2002 12:35 AM
To: struts-user@jakarta.apache.org
Subject: How to track the row id......



In a particular scenario im populating my form using logic:iterate
with data fetched based on a query the user may edit or view the same(for
each row)

lets say im populating my order form with line item enrty and the user wants
to edit or view each line item

Now how can one generate and track the row ids...do we have any tags or
attribues for any
tag to do the same.

If a tag attribute is doing the same then how can one get the index value
generated.

I have tried using
<html:link  page="/editdetails.do?action=Edit" paramId = "<% = index1 %>">
<bean:message key="edit.lineitems"/>
</html:link>
inside the logic:iterate tag

is paramId generating an index value if so how do i track/fetch it and at
the same time
if we use indexed then what should be the value of indexed attribute

do we have a clear cut solution for this scenarion...any links or resources


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message