• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:Submit with more properties

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a table with several row. For each row i need to insert a submit button to delete row.

Problem: I used the submit property to define dispatch value (method name inside the action)
How can I pass to action selected row's number id?


JSP:

<logic:iterate id="place" name="details" property="info.places" indexId="indexList">
....
<html:submit property="dispatch" styleClass="<%= buttonStyle %>">
<bean:message key="button.delete"/>
</html:submit>
</logic:iterate>


ACTION (I use LookupDispatchAction):
....
public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {

String indexId = req.getParameter("indexList"); ??? I need indexId parameter ???
...
delete record on DB
}

P.S. I can't use JavaScript

Thanks

Andrea
 
Andrea Biraghi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No solution?
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andrea Biraghi wrote:How can I pass to action selected row's number id?


You can pass it as an "query string", like
http://host/YourAction.do?rowid=3

OR
Pass row id as a hidden attribute.
JSP:



[Please this is the approach not complete code ]


 
Andrea Biraghi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sagar,
thank you for your reply but it doesn't work.

1st solution: I need to submit form. I can't use link with attributes

2nd solution: rowid is the same for every row. This value isn't dynamic! "rowid = last indexList"

Here's my code:


I tried to use indexed attribute but nothing.

Any idea?

 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andrea Biraghi wrote:1st solution: I need to submit form. I can't use link with attributes


Usually, the delete action requires a single attribute, e.g to delete "person/user" record I'll submit person id/user id and delete that row from db, If this is what you're doing then you can pass that id using link.

I don't know your html form or which property you're submitting. But to pass "id" through link, I'll use html:link tag instead of html:submit.
like

Andrea Biraghi wrote:2nd solution: rowid is the same for every row. This value isn't dynamic! "rowid = last indexList"


Sorry for that.

Finally, you need to pass an "request" attribute when you call delete action, either pass using "query string" or hidden request parameter, concentrate on that, you will get your answer.
 
Andrea Biraghi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't use html:link because I need to submit form values
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andrea Biraghi wrote:I can't use html:link because I need to submit form values


And which value you're submitting, As I quote earlier, to DELETE, you hardly require a FORM to submit. so whats your need ?

And If you still want to SUBMIT a FORM, a hidden ID can be passed any time OR If I'm not getting your requirement then read this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic