Hi, I have to develop a website using struts, most all my webpages will be add, change, delete, display type. Like, i will show about 20 records per page, each one will have a checkbox, there will be 3 buttons on bottom.. Add, Change, Delete, so if the user clicks add, i will show him add screen and add the record, if user selects one record and presses change i will show the user data where he can change and same in delete.. now how can i decide on the action class on my first display page, also the form tag, so when the user clicks add direct him to add.jsp, if change or delete to change or delete.jsp with the selected value and also have validtion like user cannot use change unless he clicks one row, also cannot click more then one row for change etc.
Using the scenario as you've outlined it... jsp1.jsp
Personally, since you only want one record to be changed or at a time, I would do something in jsp1.jsp like when each row is displayed, the "name" or whatever field, on each row is a hyperlink to the "change" action which passes the correct parameter identifying which record to change. Additionally I would display checkboxes next to each row, which when checked, indicate that you want that record deleted. Let's say you give your checkboxes names of "deleted" and values corresponding to the record number you want deleted. In that case your code would look something like this: jsp1.jsp
Hope this helps. [ August 27, 2002: Message edited by: Jason Menard ]
posted 16 years ago
Hi Jason, I really appreciate you giving such a nice answer for my question, i will build the application keeping it in mind.. thanx again
Please take this advice: do not hardcode values of buttons into an Action subclass. What if your user/client says "please make this button say 'OK' instead of 'Save'". Then you are stuck modifying Java code when simply changing ApplicationResources.properties would have sufficed. Have a look at DispatchAction or (my creation) LookupDispatchAction.
Originally posted by Erik Hatcher: Please take this advice: do not hardcode values of buttons into an Action subclass. What if your user/client says "please make this button say 'OK' instead of 'Save'". Then you are stuck modifying Java code when simply changing ApplicationResources.properties would have sufficed. Have a look at DispatchAction or (my creation) LookupDispatchAction.
This is good advice. The example is only provided for brevity and to get the point across.
Hi, Could any of you suggest on how to use LookupDispatchAction with hyper links? I have a hyper link (with <a> tag) and I need to direct this to a LookupDispatchAction. I know when you click on a <html:submit> button, it carries the key of <bean:message>, but how can I pass the same information when I click on a hyper link? I would greatly appreciate your thoughts. Thanks in advance!!!
Seriously? That's what you're going with? I prefer this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library