• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

getting Nosuchmethod exception even though there's unspecified method in the code

 
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having an issue with the struts (1.x) code when a cancel button is clicked. Here's the java code with action methods:





And here's how all the methods are called from the JSP (customerApproveType.jsp) and they all work fine when the Approve and Save buttons are clicked.



However, as soon as cancel button is clicked, I keep getting:



Why is it happening like this even though I have the following method in the code to handle cancel button related operations I believe?


 
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What makes you think the unspecified() method should be called?
 
Jack Tauson
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:What makes you think the unspecified() method should be called?



Since there is no onclick event of the cancel button like it's there for other buttons like onclick="this.form.meth.value='save'" (for example). Please explain if my thinking is incorrect here. I guess I can define an action method for the cancel button and call it like "onclick="this.form.meth.value='cancel'" but I was hoping that unspecified method would take care of it.


Thanks!
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, what I mean is, why would the cancel tag specifically call a method named "unspecified"? Why not "other" or "cancel" or any other arbitrary name?

Where did you get the method name "unspecified" from?
 
Sheriff
Posts: 28329
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This post from 18 years ago here seems to think there should be an "unspecified" method as well: Unspecified method. And there's other pages out on the web which suggest something like
These seem to be for Struts 1, some say so and others are so ancient they must be Struts 1. But then the question seems to be about Struts 1 as well. There's also a post from 10 years ago here Struts 1 No Longer Supported in which it's mentioned that the last release of Struts 1 was 15 years ago and that it was de-supported because of security issues.

I don't know the answer to the OP's question except to guess that the "unspecified" method described there isn't in a class which extends DispatchAction; using @Override would test that immediately. (Full disclosure: I'm not a Struts programmer.)
 
Sheriff
Posts: 4646
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jack Tauson wrote:Since there is no onclick event of the cancel button like it's there for other buttons like onclick="this.form.meth.value='save'" (for example). Please explain if my thinking is incorrect here. I guess I can define an action method for the cancel button and call it like "onclick="this.form.meth.value='cancel'" but I was hoping that unspecified method would take care of it. ...


As you already mentioned, there is no onclick handler defined for the Cancel button.  Is the event bubbling/propagating upwards and being handled by another element?
 
Ron McLeod
Sheriff
Posts: 4646
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never looked at Stuts before, but I am guessing that it uses convention over configuration, and that at runtime, it using reflection/introspection to try and locate the appropriate class and method to handle the event.

Most likely if you examine the URL of the request which was triggered by clicking on the Cancel button, it will become more clear which method was expected but not found.
 
Jack Tauson
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:No, what I mean is, why would the cancel tag specifically call a method named "unspecified"? Why not "other" or "cancel" or any other arbitrary name?

Where did you get the method name "unspecified" from?



The code I'm looking at is 12 years old so I've no idea. But I will try to investigate based on what others have suggested.
 
Jack Tauson
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:Most likely if you examine the URL of the request which was triggered by clicking on the Cancel button, it will become more clear which method was expected but not found.



You mean examine the URL in the network tab of the web browser (which shows up after pressing F12 in Firefox)?
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show us:

  • AbstractCustomerApproveTypeAction
  • struts-config.xml

  •  
    Jack Tauson
    Ranch Hand
    Posts: 458
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Please find the shorter version of both files below:


    AbstractCustomerApproveTypeAction




    struts-config.xml where the bean is defined for CustomerApproveTypeAction

     
    There is no "i" in denial. Tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic