• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing parameter to action method

 
John Sears
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to implement table containing a list of elements with a link to delete each element. I am using struts2 for the project.

In my action class I have a method:


that removes the item at that index.

In my JSP, I basically want the following functionality:



This doesn't seem to work though. Is there a way to pass an argument like this?

Thanks!
John
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes; like you're doing it. Is dynamic method invocation turned on? Why doesn't your method return a String? What steps have you taken to debug it so far? ItDoesntWorkIsUseless .

Note that performing destructive operations from a link can be risky if your page is crawlable.
 
John Sears
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the quick reply! I get the following message when I click on the link:

java.lang.NoSuchMethodException: *.*.*.ViewParticipant.deleteProgram()

That's why I figured that it was probably not valid to pass the parameter like that. I haven't been sure how to debug because the method never actually gets called.

Finally, if I set id as a private instance variable (with getters/setters) of the viewParticipant action, it gets set on clicking 'Delete'. So it is passing the parameter to the action, not to the method.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try creating the right method signature and see if that fixes the issue. The paradigm itself is fine; I used to use it fairly frequently.
 
John Sears
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean returning a String? I actually was already, I just miscopied that when I posted this. I have edited the first post to correct the typos in the first one (apologies for that). If you could, take a look now:
 
John Sears
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, thanks for the warning about destructive links and crawling. This page is going to be behind an authentication system and will be inaccessible to web crawlers.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google desktop.
 
John Sears
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well it will be running on a linux server, so hopefully not. In any case, any ideas why it would not be working?
 
Aj Kot
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to struts2 how to make the dynamic method invocation turned on?please advice on the jsp nested custom tags issue as well.
Did you got any solution to this problem,i am having similar Issue where the getter is not getting called in the action.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Java struts: Please read the JavaRanch naming policy and fix your name accordingly. That aside, that's not even legal JSP--you can't nest custom tags like that. Also, please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

@John: So far I'm not sure. Maybe post the complete configuration for the action, the HTML/JavaScript rendered, etc. Is dynamic method invocation turned on?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic