wood burning stoves 2.0*
The moose likes Struts and the fly likes accessKey and optionsCollection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "accessKey and optionsCollection" Watch "accessKey and optionsCollection" New topic
Author

accessKey and optionsCollection

Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hello friends ,

This time its 3 questions. Would need your help.

1) I want to be able to make the user use the keyboard character to access certain field on my form. there is an attribute called "accessKey" which can be used for this purpose for the html:form tag. I dont know how practically this can be done. I tried googling around but did not yield any results. May be the way i am finding may be wrong.

2) for the html ptionsCollection tag what does the label and value stand for ? It is confusing me.

3) Wanted to what is the difference between <html:errors/> and <html:messages/> ?

Can anyone suggest on this please ?

Also i would like to know if there is some book available which gives practical examples on all the Struts html,bean,logic tags. I really would like to have a book which gives practical examples on all the struts taglibs.

Best regards,

Yogendra Joshi
[ October 27, 2006: Message edited by: Yogendra Joshi ]

Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Yogendra Joshi:
1) I want to be able to make the user use the keyboard character to access certain field on my form. there is an attribute called "accessKey" which can be used for this purpose for the html:form tag. I dont know how practically this can be done. I tried googling around but did not yield any results. May be the way i am finding may be wrong.

The accesskey attribute is a pass-through attribute, meaning that a Struts input tag such as <html:text> will just pass the attribute on to the generated HTML <input> tag. You can find more information about it in this link..
Originally posted by Yogendra Joshi:
2) for the htmlptionsCollection tag what does the label and value stand for ? It is confusing me.

You use <htmlptionsCollection> when you have a collection of JavaBeans for which you want one of the bean properties to represent the value of the option and the other to represent the label or publicly visible part of the option. You specify the bean property to be used for the value in the value attribute and the bean property to be used for the label with the label attribute of the tag.
Originally posted by Yogendra Joshi:
3) Wanted to what is the difference between <html:errors/> and <html:messages/> ?

See the headings "Displaying Messages" and "Displaying Error Messages" in this link.


Merrill
Consultant, Sima Solutions
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Thanks Merrill for your help. One more question..

The day before i tried using 2 Message properties file for my application. I wanted to test to have displaying the messages from 2 different resource bundles. For that there is an attribute called bundle of the bean:message tag. I tried doing it like this on my JSP :

<bean:message key="yogendra.test" bundle="resources.Messages">
and the other one like this :

<bean:message key="welcome.title" bundle="MessagesResources">

I have added 2 message-resources element in the struts-config.xml file , restarted the server mannier times but it always gives an error saying "No key found under the name MessagesResources or resources.Messages". If i remove one of them from struts-config.xml file , It just works fine. Can you let me know how can i get messages from both the files at once ??

Thanks in Advance again.

Yogendra N Joshi.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Whenever you have more than one Message Resource bundle, all but one of them has to have a key attribute specified when you define the bundle in the struts-config.xml file. Example:

<message-resources key="moreResources" parameter="com.mycompany.MoreApplicationResources"/>

Then, when you refer to this bundle you must specify a bundle attribute. Example:

<bean:message key="name.label" bundle="moreResources" />

Any resource without a key attribute is considered to be the default message resource, and can be referred to without a bundle attribute in the <bean:message> tag.
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
yes, Merrill it worked like Butter... :-)

Thanks for the immediate help. You've always been helpful. If like Sun Forums i would have had Duke Dollars , I would have given you all my 10 Dollars :-)

thanks again.

Yogendra N Joshi.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: accessKey and optionsCollection
 
Similar Threads
nothing is happening in action class when i submit a page(struts )
Logout problem.
c:redirect not working
Http redirect question.
Struts Message-Resources