You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ma...@yahoo.com on 2007/04/02 03:23:22 UTC

confused about validation

Hello everyone:
I am totally new to struts. I decided to go with struts 2. But the 
documentation is not complete, and I believe alot of you may agree with me.

The example on this page 
http://struts.apache.org/2.0.6/docs/validating-input.html  says that the 
validation file follows the name convention  SomeAction-validaton.xml. 
In the field validation example in the showcase application in struts 2 
distribution,  the name of the file is struts-validation.xml. Now, none 
of the examples are working for me basically because none of them is 
complete. The one in the show case is great but there no explanation for 
the code.
For example what is the name space here in struts applications ?

Can some one look into what I did and advice me what to do next ? I have 
a webpage called newAccount.jsp:

<%@ taglib prefix="s" uri="/struts-tags"%>
<s:form action="createAccount"   >
<s:textfield name="firstName" label="First Name" required="true"  
 ></s:textfield>
<s:textfield name="lastName" label="Last Name" />
</s:form>

I need to validate the fields in this page, so I did this in 
Account-Validation.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

<validators>
    <field name="firstName">
        <field-validator   type="requiredstring">
            <message>first name is required</message>
        </field-validator>
    </field>
</validators>


and in my struts.xml I did this:

        <action name="createAccount"  class="billing.Account">
            <result name="SUCCESS">/pages/accountView.jsp</result>
             <result name="ERROR">/pages/exception.jsp</result>
        </action>
       


but nothing is happening and no validation is taking place. can any one 
kindly recommend something?

Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by Ted Husted <hu...@apache.org>.
On 4/2/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
> Is 't possible (easy) to add a master index, so users can search that
> page using a key word ?
> So if I am looking for theme, I can easily find all the pages that deals
> with this term.
> I think this can help.

Confluence provides a "label" feature. From "Browse Site", we can
select the label tag, and then view a list of pages by label. Right
now, we're mainly using labels to tag the "experimental" features.

Indexing a site (or a book) is not a trivial task, but it is helpful,
if someone has the time.

> having a reliable search service is another option.

"Reliable" is a complex word. The HTML version of the site has a
Google search feature that seems to work well for me. On the
Confluence side, we can narrow the search to the Struts Documentation
space. But, it's still a simple keyword search.

HTH, Ted
<http://www.husted.com/ted/blog/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by ma...@yahoo.com.
Ted Husted wrote:
> On 4/2/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
>> The first thing I would do is fixing the broken links. For example if
>> you go to the page:
>> http://struts.apache.org/2.0.6/docs/basic-validation.html
>
> The problem with links like these is that the path is pointing to the
> "java" folder rather than the "resources" folder. Anyone with a CLA on
> file can find and fix these.
>
> The changes won't show up on the */2.0.6/* version, since that is a
> historical archive. But they will show up on the */2.x/* draft
> version.
>
>
>> Second thing I will re factor the documentation and try to keep all the
>> links on one single page. For example,
>> I will put all the
>> details of selecting a type found on this page
>> http://struts.apache.org/2.0.6/docs/result-types.html, under the link
>>
>> "Selecting Results
>> <http://struts.apache.org/2.0.6/docs/selecting-results.html> We setup
>> different results for different result codes."
>
> That could be done by using the Confluence include macro, so that the
> content is not duplicated.
>
>
>> As you can see from questions, the answers were there, but I couldn't
>> reach them. This tells that the documentation is sufficient to get a
>> newbie started, but the information has to be placed in a handy place so
>> that they can be easily reached.
>
> I wish I knew how to make it better, but, honestly, I don't. The wiki
> format is great for group editing, but it's very difficult to make
> sweeping changes to the organization.
Is 't possible (easy) to add a master index, so users can search that 
page using a key word ?
So if I am looking for theme, I can easily find all the pages that deals 
with this term.
I think this can help.
having a reliable search service is another option.


>
>
>>
>> The problem I am running into right now is how to control the location
>> of the validation error. My guess is to use css,
>> but I am looking for an example. I have feeling that it's there
>> somewhere there on the site, but the problem is how to find it.
>
> The location of the validation error messages is determined by the theme.
>
> * http://struts.apache.org/2.x/docs/extending-themes.html
>
>
>> I will let you know if I noticed any thing else that can be adjusted and
>> provide you with the suggestion.
>
> The best thing might to be file JIRA tickets with very specific
> suggestions, or, alternatively, file a CLA, and implement the changes
> directly.
>
> * http://struts.apache.org/2.x/docs/editing-the-documentation.html
>
> -Ted.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by Ted Husted <hu...@apache.org>.
On 4/2/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
> The first thing I would do is fixing the broken links. For example if
> you go to the page:
> http://struts.apache.org/2.0.6/docs/basic-validation.html

The problem with links like these is that the path is pointing to the
"java" folder rather than the "resources" folder. Anyone with a CLA on
file can find and fix these.

The changes won't show up on the */2.0.6/* version, since that is a
historical archive. But they will show up on the */2.x/* draft
version.


> Second thing I will re factor the documentation and try to keep all the
> links on one single page. For example,
> I will put all the
> details of selecting a type found on this page
> http://struts.apache.org/2.0.6/docs/result-types.html, under the link
>
> "Selecting Results
> <http://struts.apache.org/2.0.6/docs/selecting-results.html> We setup
> different results for different result codes."

That could be done by using the Confluence include macro, so that the
content is not duplicated.


> As you can see from questions, the answers were there, but I couldn't
> reach them. This tells that the documentation is sufficient to get a
> newbie started, but the information has to be placed in a handy place so
> that they can be easily reached.

I wish I knew how to make it better, but, honestly, I don't. The wiki
format is great for group editing, but it's very difficult to make
sweeping changes to the organization.


>
> The problem I am running into right now is how to control the location
> of the validation error. My guess is to use css,
> but I am looking for an example. I have feeling that it's there
> somewhere there on the site, but the problem is how to find it.

The location of the validation error messages is determined by the theme.

* http://struts.apache.org/2.x/docs/extending-themes.html


> I will let you know if I noticed any thing else that can be adjusted and
> provide you with the suggestion.

The best thing might to be file JIRA tickets with very specific
suggestions, or, alternatively, file a CLA, and implement the changes
directly.

* http://struts.apache.org/2.x/docs/editing-the-documentation.html

-Ted.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by ma...@yahoo.com.
Ted Husted wrote:
> I'd say that someone who is learning the framework is in the best
> position to know what other newbies need to know.
>
> What specific changes could we (meaning you) make to the documentation
> so that someone else wouldn't have the same problem.
>
> On 4/1/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
>> Thank you, I really appreciate your help. Definitely there's a lot of
>> room for improvement for the documentation, but unfortunately I am still
>> not at a point where I can guide others.  :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

The first thing I would do is fixing the broken links. For example if 
you go to the page:
http://struts.apache.org/2.0.6/docs/basic-validation.html

you'll find this error at the bottom:

An error occurred: 
http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/QuizAction-validation.xml. 
The system administrator has been notified.

and all the validation examples will have the same error.


Second thing I will re factor the documentation and try to keep all the 
links on one single page. For example,
I will put all the
details of selecting a type found on this page 
http://struts.apache.org/2.0.6/docs/result-types.html, under the link

"Selecting Results 
<http://struts.apache.org/2.0.6/docs/selecting-results.html> We setup 
different results for different result codes."

on the first page of the tutorial. I you may think this doesn't make 
lots of difference as the material exist already. But I the links for 
detail explanation at the bottom of every page is no very obvious to 
find, and it will take time for the visitor of the site to find what she 
is looking for.  And it's easier to search and navigate back and forth.

As you can see from questions, the answers were there, but I couldn't 
reach them. This tells that the documentation is sufficient to get a 
newbie started, but the information has to be placed in a handy place so 
that they can be easily reached.

The problem I am running into right now is how to control the location 
of the validation error. My guess is to use css,
but I am looking for an example. I have feeling that it's there 
somewhere there on the site, but the problem is how to find it.

I will let you know if I noticed any thing else that can be adjusted and 
provide you with the suggestion.







---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by Ted Husted <hu...@apache.org>.
I'd say that someone who is learning the framework is in the best
position to know what other newbies need to know.

What specific changes could we (meaning you) make to the documentation
so that someone else wouldn't have the same problem.

On 4/1/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
> Thank you, I really appreciate your help. Definitely there's a lot of
> room for improvement for the documentation, but unfortunately I am still
> not at a point where I can guide others.  :)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by ma...@yahoo.com.
Dave Newton wrote:
> --- mansour77@yahoo.com wrote:
>   
>> Thank you Dave:
>> It's working fine now.
>>     
>
> Cool...
>
> Always feel free to post with documentation
> observations or make a comment directly on the Wiki
> page in question; there's a growing body of
> documentation editors churning away :)
>
> d.
>
>
>
>  
> ____________________________________________________________________________________
> Don't pick lemons.
> See all the new 2007 cars at Yahoo! Autos.
> http://autos.yahoo.com/new_cars.html 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   
Thank you, I really appreciate your help. Definitely there's a lot of 
room for improvement for the documentation, but unfortunately I am still 
not at a point where I can guide others.  :)



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by Dave Newton <ne...@yahoo.com>.
--- mansour77@yahoo.com wrote:
> Thank you Dave:
> It's working fine now.

Cool...

Always feel free to post with documentation
observations or make a comment directly on the Wiki
page in question; there's a growing body of
documentation editors churning away :)

d.



 
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by ma...@yahoo.com.
Dave Newton wrote:
> --- mansour77@yahoo.com wrote:
>   
>> Now I getting totally different error:
>>
>>
>> HTTP Status 500 -
>>
>>     
> ------------------------------------------------------------------------
>   
>> *type* Exception report
>> *message*
>> *description* _The server encountered an internal
>> error () that 
>> prevented it from fulfilling this request._
>> *exception*
>>
>> No result defined for action billing.Account and
>> result input - action -
>>
>>     
> file:/home/mansour/workspace/Invoice/WEB-INF/classes/struts.xml:12:64
>
> <action name="createAccount"  class="billing.Account">
>   <result name="SUCCESS">
>     /pages/accountView.jsp
>   </result>
>   <result name="ERROR">
>     /pages/exception.jsp
>   </result>
> </action>
>        
> Well, you *don't* have a result for "input", which is
> exactly what the error message says.
>
> Also, the built-in result names are lowercase,
> "success" and "error" etc. just like in the tutorials.
>
> http://struts.apache.org/2.0.6/docs/tutorials.html
> http://struts.apache.org/2.0.6/docs/bootstrap.html
>
> d.
>
>
>
>  
> ____________________________________________________________________________________
> Bored stiff? Loosen up... 
> Download and play hundreds of games for free on Yahoo! Games.
> http://games.yahoo.com/games/front
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   
Thank you Dave:
It's working fine now.




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by Dave Newton <ne...@yahoo.com>.
--- mansour77@yahoo.com wrote:
> Now I getting totally different error:
> 
> 
> HTTP Status 500 -
>
------------------------------------------------------------------------
> *type* Exception report
> *message*
> *description* _The server encountered an internal
> error () that 
> prevented it from fulfilling this request._
> *exception*
> 
> No result defined for action billing.Account and
> result input - action -
>
file:/home/mansour/workspace/Invoice/WEB-INF/classes/struts.xml:12:64

<action name="createAccount"  class="billing.Account">
  <result name="SUCCESS">
    /pages/accountView.jsp
  </result>
  <result name="ERROR">
    /pages/exception.jsp
  </result>
</action>
       
Well, you *don't* have a result for "input", which is
exactly what the error message says.

Also, the built-in result names are lowercase,
"success" and "error" etc. just like in the tutorials.

http://struts.apache.org/2.0.6/docs/tutorials.html
http://struts.apache.org/2.0.6/docs/bootstrap.html

d.



 
____________________________________________________________________________________
Bored stiff? Loosen up... 
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by ma...@yahoo.com.
mansour77@yahoo.com wrote:
> Ted Husted wrote:
>> On 4/1/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
>>> For example what is the name space here in struts applications ?
>>
>> * http://struts.apache.org/2.x/docs/namespace-configuration.html
>>
>> The namespace should not affect validation.
>>
>>> but nothing is happening and no validation is taking place. can any one
>>> kindly recommend something?
>>
>> You may need to use a lowercase v in -validation.
>
> I just checked and it's lowercase.
>>
>> At runtime, is the Account-validation.xml in the same package/folder
>> as the Java class?
> No it's not. I moved it to the package, but now I am getting error 
> that the action is not found !
>
>
>
> HTTP Status 404 - /Invoice/pages/createAccount.action
>
> ------------------------------------------------------------------------
>
> *type* Status report
>
> *message* _/Invoice/pages/createAccount.action_
>
> *description* _The requested resource 
> (/Invoice/pages/createAccount.action) is not available._
>
> ------------------------------------------------------------------------
>
> Apache Tomcat/6.0.2
>
>
>
> However, the error shows that it's using wrong path for the action. If 
> I know how to rectify this, I this I will make a progress.
>
> Thank you for your help.
>
>
>>
>> -Ted.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
Now I getting totally different error:


HTTP Status 500 -
------------------------------------------------------------------------
*type* Exception report
*message*
*description* _The server encountered an internal error () that 
prevented it from fulfilling this request._
*exception*

No result defined for action billing.Account and result input - action - file:/home/mansour/workspace/Invoice/WEB-INF/classes/struts.xml:12:64





Any Idea what's going on


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: confused about validation

Posted by ma...@yahoo.com.
Ted Husted wrote:
> On 4/1/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
>> For example what is the name space here in struts applications ?
>
> * http://struts.apache.org/2.x/docs/namespace-configuration.html
>
> The namespace should not affect validation.
>
>> but nothing is happening and no validation is taking place. can any one
>> kindly recommend something?
>
> You may need to use a lowercase v in -validation.

I just checked and it's lowercase.
>
> At runtime, is the Account-validation.xml in the same package/folder
> as the Java class?
No it's not. I moved it to the package, but now I am getting error that 
the action is not found !



HTTP Status 404 - /Invoice/pages/createAccount.action

------------------------------------------------------------------------

*type* Status report

*message* _/Invoice/pages/createAccount.action_

*description* _The requested resource 
(/Invoice/pages/createAccount.action) is not available._

------------------------------------------------------------------------

Apache Tomcat/6.0.2



However, the error shows that it's using wrong path for the action. If I 
know how to rectify this, I this I will make a progress.

Thank you for your help.


>
> -Ted.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>





Re: confused about validation

Posted by Ted Husted <hu...@apache.org>.
On 4/1/07, mansour77@yahoo.com <ma...@yahoo.com> wrote:
> For example what is the name space here in struts applications ?

* http://struts.apache.org/2.x/docs/namespace-configuration.html

The namespace should not affect validation.

> but nothing is happening and no validation is taking place. can any one
> kindly recommend something?

You may need to use a lowercase v in -validation.

At runtime, is the Account-validation.xml in the same package/folder
as the Java class?

-Ted.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org