Struts2 URL problem
Hi I have the following problem with url in my web application: I run my app using Struts2 and Tomcat6. Context name of webapp: MY_WEB Namespace in my package tag of struts-config.xml: package name="register" namespace="/register" extends="tiles-default" Mapping of Action class in my struts-config.xml : action name= acc.register.RegistrationForm A Href link in my jsp page: a href="register/acc.register.RegistrationForm.do" Now, the following url works fine when I launch my app: http://localhost:8080/MY_WEB/register/acc.register.RegistrationForm.do But the problem is the url when added something between my packagename(register)and my uri (acc.register.RegistrationForm.do) like following: http://localhost:8080/MY_WEB/register/somecrap/acc.register.RegistrationForm.do it still works fine instead of displaying the error page. I need to get an error page if I give wrong url like the above. What is my mistake ? Pls advise. -- View this message in context: http://www.nabble.com/Struts2-URL-problem-tp16020941p16020941.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 URL problem
Thanks Jeromy! Ive tried creating a package with empty name space ie : then the following url : http://localhost:8080/MY_WEB/acc.register.RegistrationForm.do without the namespace works fine .. But any other way to keep my namespace in tact in the url because the above may not be acceptable? Thanks, Tauri http://localhost:8080/MY_WEB/register/acc.register.RegistrationForm.do Jeromy Evans - Blue Sky Minds wrote: > > No mistake. AFAIK that's a design flaw of the default action mapper. > > See: > http://www.planetstruts.org/struts2-blank/example/somecrap/HelloWorld.action > > If there's no match in a package namespace it falls back to the default > package and matches a little to generously. > > You may be able to avoid it by creating a package with an empty > namespace containing no actions. Not sure about that one... > > Tauri Valor wrote: >> Hi >> >> I have the following problem with url in my web application: >> >> I run my app using Struts2 and Tomcat6. >> >> Context name of webapp: MY_WEB >> >> Namespace in my package tag of struts-config.xml: >> >> package name="register" namespace="/register" extends="tiles-default" >> >> >> Mapping of Action class in my struts-config.xml : >> >> action name= acc.register.RegistrationForm >> >> >> A Href link in my jsp page: >> >> >> a href="register/acc.register.RegistrationForm.do" >> >> >> >> Now, the following url works fine when I launch my app: >> >> http://localhost:8080/MY_WEB/register/acc.register.RegistrationForm.do >> >> >> But the problem is the url when added something between my >> packagename(register)and my uri (acc.register.RegistrationForm.do) like >> following: >> >> http://localhost:8080/MY_WEB/register/somecrap/acc.register.RegistrationForm.do >> >> it still works fine instead of displaying the error page. I need to get >> an >> error page if I give wrong url like the above. >> >> What is my mistake ? >> >> Pls advise. >> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-URL-problem-tp16020941p16021626.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 URL problem
Thanks Jeromy! I tried all the four solutions that youve provided..but I still have the same problem. :) Im still unable to get the error page for the wrong url with the scrappy namespace in the addressbar. If you have thought of any other solution pls let me know. I will try and let you know.. Thanks again for your time.. Thanks, Tauri. Jeromy Evans - Blue Sky Minds wrote: > > Hi Tauri, > > I don't have time to try it myself right now, but what I meant was > create an additional default package that contains no actions. I'm not > sure if it will help though. The idea is that when the default action > mapper can't match the namespace, it falls back to an empty back. > > Like this: > > > > ...normal actions... > > > > ie. create an empty back in the "" namespace. If that doesn't work also > try the "/" namespace. > > If that doesn't work, there's also some poorly documented options for > the default ActionMapper. > Try setting the struts property > "struts.mapper.alwaysSelectFullNamespace" to true. It may be the one > you need. Put it in struts.properties or a const in struts.xml. > > Hope that helps, > Jeromy Evans > > Tauri Valor wrote: >> Thanks Jeromy! >> >> Ive tried creating a package with empty name space ie : >> >> >> >> then the following url : >> >> http://localhost:8080/MY_WEB/acc.register.RegistrationForm.do >> >> without the namespace works fine .. >> >> But any other way to keep my namespace in tact in the url because the >> above >> may not be acceptable? >> >> Thanks, >> Tauri >> >> >> >> >> http://localhost:8080/MY_WEB/register/acc.register.RegistrationForm.do >> >> >> >> >> >> >> >> >> >> Jeromy Evans - Blue Sky Minds wrote: >> >>> No mistake. AFAIK that's a design flaw of the default action mapper. >>> >>> See: >>> http://www.planetstruts.org/struts2-blank/example/somecrap/HelloWorld.action >>> >>> If there's no match in a package namespace it falls back to the default >>> package and matches a little to generously. >>> >>> You may be able to avoid it by creating a package with an empty >>> namespace containing no actions. Not sure about that one... >>> >>> Tauri Valor wrote: >>> >>>> Hi >>>> >>>> I have the following problem with url in my web application: >>>> >>>> I run my app using Struts2 and Tomcat6. >>>> >>>> Context name of webapp: MY_WEB >>>> >>>> Namespace in my package tag of struts-config.xml: >>>> >>>> package name="register" namespace="/register" extends="tiles-default" >>>> >>>> >>>> Mapping of Action class in my struts-config.xml : >>>> >>>> action name= acc.register.RegistrationForm >>>> >>>> >>>> A Href link in my jsp page: >>>> >>>> >>>> a href="register/acc.register.RegistrationForm.do" >>>> >>>> >>>> >>>> Now, the following url works fine when I launch my app: >>>> >>>> http://localhost:8080/MY_WEB/register/acc.register.RegistrationForm.do >>>> >>>> >>>> But the problem is the url when added something between my >>>> packagename(register)and my uri (acc.register.RegistrationForm.do) like >>>> following: >>>> >>>> http://localhost:8080/MY_WEB/register/somecrap/acc.register.RegistrationForm.do >>>> >>>> it still works fine instead of displaying the error page. I need to get >>>> an >>>> error page if I give wrong url like the above. >>>> >>>> What is my mistake ? >>>> >>>> Pls advise. >>>> >>>> >>> - >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >>> >> >> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-URL-problem-tp16020941p16087758.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 URL problem
Thanks Jeromy I will try your approach and let you know. Jeromy Evans - Blue Sky Minds wrote: > > At this point I'd either > a) accept it, because it's unlikely to cause really problems or ever be > noticed by a real user. It's just scrappy > b) create a custom ActionMapper derived from the default one that > removes that feature > c) Use a plugin that does b for you > > I don't use the DefaultActionMapper myself any more. > > Option b is not as difficult as it may first seem. The default code is > quite straight-forward [1], [2] > > As you're using Struts 2.0 you can't use the new Convention plugin. As > you're using struts.xml rather than CodeBehind I don't recommend > switching to the SmartURLs plugin as you'll have to re-check all the > configuration (unless it's a small application) [3]. The > Struts2UrlPlugin [4] will fix the problem immediately by dropping the > jar into the classpath but it's not released yet, undocumented and is > probably overkill. > > So I recommend a) or b). > > [1] http://struts.apache.org/2.x/docs/actionmapper.html > [2] > http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?view=markup > [3] http://cwiki.apache.org/S2PLUGINS/smarturls-plugin.html > [4] http://code.google.com/p/struts2urlplugin/ > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-URL-problem-tp16020941p16089143.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts2 Annotation based Validation
Using Annotation based Validation, I want to try the following: The Validation Error message can be retrieved in our jsp using : Do I have any alternative method of using the above tags ? For eg. can I retrieve the error using session.getAttribute(actionerror) ? Are actionerror and fielderror stored in a request or a session object ? Please help me understand this . Thanks, Tauri. -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16089678.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Thanks Lukasz! I tried request.getAttribute("actionerror") and request.getAttribute("fielderror") in my jsp but it did not work. Am I doing it the wrong way ? Lukasz Lenart wrote: > > Hi, > > Error messages are stored in request, you have to subclass > ActionSupport and add some mechanism to store messages in session. > > > Regards > -- > Lukasz > > http://www.linkedin.com/in/lukaszlenart > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16090926.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Thanks Jeromy and Lukasz! I could manage to get the field specific error messages using : firstName I have a new problem, when validating the page I get error messages as desired. Eg: Mandatory field validation gives out message saying "Field is mandatory". But when I enter the value in the textbox and click submit again, the validation error for next is displayed correctly but entered value disappears in the textbox which is abnormal . Why is this happening ? Please help me understand. Thanks, Tauri Lukasz Lenart wrote: > >> In Struts2 error messages are stored in the ValueStack in an object > > Yes, I made mistake, I've mean in request scope, not in request object ;-) > > > Regards > -- > Lukasz > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16115634.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Hi Lukasz, Thanks for responding.. Snippet of Jsp: First Name firstName My Struts-config: MyForm MyForm SuccessPage Thats the snippet of my code. Thanks, Tauri. Lukasz Lenart wrote: > >> But when I enter the value in the textbox and click submit again, the >> validation error for next is displayed correctly but entered value >> disappears in the textbox which is abnormal . > > Maybe you are redirecting to the next page? Could you paste snippet > for your struts.xml and jsp? > > > Regards > -- > Lukasz > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16116146.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
I get the following log in my console: 2008-Mar-18 16:21:17,671 - DEBUG freemarker.cache - Could not find template in cache, creating new one; id=[template/xhtml/fielderror.ftl[en_US,UTF-8,parsed] ] 2008-Mar-18 16:21:17,671 - DEBUG freemarker.cache - template/simple/fielderror.ftl[en_US,UTF-8,parsed] cached copy not yet stale; using cached. Does it have anything to do with caching of the page? Thanks, Tauri. Tauri Valor wrote: > > Hi Lukasz, > > Thanks for responding.. > > Snippet of Jsp: > > > > > > >width="115">First Name >width="142"> id="firstName" class="form_field"> > > > > > > > firstName > > > > > > > My Struts-config: > > > MyForm > MyForm > SuccessPage > > > > > > > Thats the snippet of my code. > > > Thanks, > Tauri. > > > Lukasz Lenart wrote: >> >>> But when I enter the value in the textbox and click submit again, the >>> validation error for next is displayed correctly but entered value >>> disappears in the textbox which is abnormal . >> >> Maybe you are redirecting to the next page? Could you paste snippet >> for your struts.xml and jsp? >> >> >> Regards >> -- >> Lukasz >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16116284.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Thanks Lukasz it worked for textfields using But I have the same problem when I use it for this is my listbox: And my password fields: Please suggest. Thanks, Tauri I used Lukasz Lenart wrote: > >> >> >> >> First Name >> >> > class="form_field"> >> >> >> >> >> >> >> >> firstName >> >> >> >> > > But as I see, you don't use for your form and that's way > you don't see values in the form. If you want to add html tags as > above, use theme=simple and s:textfield > > > Regards > -- > Lukasz > > http://www.linkedin.com/in/lukaszlenart > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16118342.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Thanks Lukasz Lukasz Lenart wrote: > >> > > By default s:password tag don't shows value of your password, you can > change such behaviour by adding attribute showPassword=true, but you > should consider security issue. > > > Regards > -- > Lukasz > > http://www.linkedin.com/in/lukaszlenart > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16296676.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Hi Is it possible for me to have multilingual Validations using Annotation Based Validations in Struts2 ? Please let me know how I can achieve this . Thanks, Tauri. Tauri Valor wrote: > > Thanks Lukasz > > > > Lukasz Lenart wrote: >> >>> >> >> By default s:password tag don't shows value of your password, you can >> change such behaviour by adding attribute showPassword=true, but you >> should consider security issue. >> >> >> Regards >> -- >> Lukasz >> >> http://www.linkedin.com/in/lukaszlenart >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16296680.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Thanks again. I tried the following: In my action: @RequiredStringValidator(key = "error.message", message = "") public String getFirstName() { return firstName; } I created the properties file just under my action with the name "MyActionName.properties" with the following contents: error.message = ${getText(firstName)} is required. fieldFormat = ${getText(fieldName)} is not formatted properly. But I do not the error message as: "error.message" instead of "firstName is required" Where am I erring ? Thanks, Tauri Lukasz Lenart wrote: > >> Is it possible for me to have multilingual Validations using Annotation >> Based Validations in Struts2 ? > > Yes, you can, just add key = some.error.message to your annotation, like > below > > @RequiredStringValidator(key = "some.key") > public void setFirstName(String firstName) { > this.firstName = firstName; > } > > > > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16297696.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Annotation based Validation
Lukasz, I tried as you advised. I get the default error message 'Please enter a value for first name ' which is in the "message" . Im expecting the error messaage from the properties file. I think Im placing my properties file in the wrong location. And therefore my validation returns me the default error message. Im not sure where to place my properties file. Thanks, Tauri. Lukasz Lenart wrote: > > You mess too many thing, please try like this: > > @RequiredStringValidator(key = "error.required", message = "Please > enter a value for First name") > > error.required = ${fieldName} is required! > > -- View this message in context: http://www.nabble.com/Struts2-Annotation-based-Validation-tp16089678p16320151.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using jsp tag in Value attribute of textfield tag in Struts2
Hi Is there a way to include value for textfield tag in struts2 , Im trying the following : But I get tld error.. Please let me know how I could use jsp tag in the textfield tag, or let me know an alternative... Thanks in Advance, Tauri. -- View this message in context: http://www.nabble.com/Using-jsp-tag-in-Value-attribute-of-textfield-tag-in-Struts2-tp16602523p16602523.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using jsp tag in Value attribute of textfield tag in Struts2
I get the following error : According to TLD or attribute directive in tag file, attribute value does not accept any expressions I could get the value using html tag '>' Thanks, Tauri. Tauri Valor wrote: > > Hi > > Is there a way to include value for textfield tag in struts2 , Im trying > the following : > > >value="<%=freshUser.getFirstName() %>"/> > > > But I get tld error.. > > Please let me know how I could use jsp tag in the textfield tag, or let me > know an alternative... > > Thanks in Advance, > Tauri. > -- View this message in context: http://www.nabble.com/Using-jsp-tag-in-Value-attribute-of-textfield-tag-in-Struts2-tp16602523p16603834.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]