aspose file tools*
The moose likes Struts and the fly likes Struts2 concepts doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 concepts doubts" Watch "Struts2 concepts doubts" New topic
Author

Struts2 concepts doubts

p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92

I have some doubts in Struts2.1. Please clarify...

1. Can annotation validations be performed in Struts2.1.


2. How do I specify in Actionclass-validation.xml file that a numeric field cannot accept alphabets.
Is this the correct validator
<field-validator type="conversion"> in validation.xml


3. We need to specify <result name="input">Login.jsp</result> , so that if there are any valiation errors this input jsp page will be displayed.
But
What is the use of <result name="error">/tutorial/error.jsp</result> in struts.xml.

4. Do we have to place Actionclass-Validation.xml file in WEB-INF-> classes folder only

5. Is this tag mandatory to perform AJAX validation
<s:url id="url" namespace="/validation" action="quizAjax"/>

6. Must we specify <s:fielderror/> in JSP for field validators and <s:actionerror/> in JSP for non field validators.Is this mandatory.

7. Please suggest a good website with some examples for learning testing struts2 Actions ,Interceptors using JUnit

8. How do we debug a struts2 application in Eclipse.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

>> 1. Can annotation validations be performed in Struts2.1.

Yes; did something lead you to believe they couldn't?

>> 2. How do I specify in Actionclass-validation.xml file that a numeric field cannot accept alphabets. Is this the correct validator <field-validator type="conversion"> in validation.xml

Normally you wouldn't need to, just use an int validator, but what precisely to do depends on your requirements and the type of the backing property (int and Integer behave differently).

>> What is the use of <result name="error">/tutorial/error.jsp</result> in struts.xml.

What do you mean "what is the use of"? It's a mapping for a result named "error" that uses a specific page--I have no idea what it's for beyond that--whoever wrote it probably knows, though.

>> 4. Do we have to place Actionclass-Validation.xml file in WEB-INF-> classes folder only

Yes. I'm sure it would be easy to hack in support for something else, but I don't know why you'd want to.

>> 5. Is this tag mandatory to perform AJAX validation
>> <s:url id="url" namespace="/validation" action="quizAjax"/>

What do you mean?

>> 6. Must we specify <s:fielderror/> in JSP for field validators and <s:actionerror/> in JSP for non field validators.Is this mandatory.

No, it's not mandatory; the just display a list of field or action errors.

>> 7. Please suggest a good website with some examples for learning testing struts2 Actions ,Interceptors using JUnit

The Struts 2 wiki?

>> 8. How do we debug a struts2 application in Eclipse.

Same as any other web application.
p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92
Thank you for taking time and answering all my questions.


1. I didnt understand the purpose of this tag
<s:url id="url" namespace="/validation" action="quizAjax"/>

2. How do we debug a struts2 application.I do not really know how to debug an application.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

p hasini wrote:1. I didnt understand the purpose of this tag
<s:url id="url" namespace="/validation" action="quizAjax"/>

It just creates a URL that can be used in-place, or referenced later.
2. How do we debug a struts2 application.I do not really know how to debug an application.

Depends on your setup, but in general you should just be able to set breakpoints like any other application.
 
Consider Paul's rocket mass heater.
 
subject: Struts2 concepts doubts