• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

struts2 newbie: (1) how to validate without xml & (2) how to have a dispatchAction?

 
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey,

Just started using struts2, my first reaction is WOW...the 'interception' is a great idea and finally the struts-config doesn't have the size of the bible :-)

Anyway, since this is my first-dummy-application, I'm struggling with the following:

1. Assuming I have a form (myusername, mypassword) and I would like to verify that the user has input the information - is there a way to do that without the XXXX-validation.xml? if so how?

2. [assuming] I have 10 buttons on the screen, in what way can I assign a dispatchAction?

I have something like this:



say I wish button.doA to do actionA() and button.doB to do actionB()...?

I realized that the

public String intercept(ActionInvocation actionInvocation) throws Exception
{
.
.
actionInvocation.invoke() runs the execute of the Action.

thanks for any pointers
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regarding validation without XML, you can use annotations instead. See this link for more information.

Regarding DispatchAction: Since in Struts2 you can specify a different action for each submit button, any action class can perform the function of the Struts 1 DispatchAction.
Example:
struts.xml

Login action class

Login.jsp
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Merrill!

Both are working fine for me!

One issue still remain: I realized that the 'compiler compliance level' suppose to be 5 (for the @ annotation and others). I set my application as level 5 and @ annotation works fine. Problem is that I have this annoying red X on the project and the "Java Resources folder"- signaling that something is wrong (and yet it's working).

Just to eliminate my paranoia- why is it like this and how can I remove it?

1. I did clean on the project, I refresh, I restarted
2. In the project's Libraries I have JRE System Library [jre1.5.0_10]


Thank you
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever you get a red "X" in Eclipse, it should show you the reason for the problem in the tasks or problems view. If you see what the problem is, but still don't know how to solve it, post it here.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved!

problem:
Java compiler level does not match the version of the installed Java project facet

Solution:
Right click Project --> Properties --> Project Facets
and changed the Java version to 5.0

Thank you Merrill!
 
it's a teeny, tiny, wafer thin ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic