Re: Where is the documentation for Struts tags ....
So if it's looking for a string, let's make sure you're giving it one, and not the .toString of an empty map that it got from your prepare method: s:checkboxlist name=%{'selectedroles'} list=%{availableroles} value=%{preselectedroles}/ I must admit I don't understand what you expect this to submit, or how that should become a map -- there are only one set of values, not pairs...Even if you get this to render the html I'm guessing that you expect: input type=checkbox name=selectedroles value=ROLE_ADMIN id=selectedroles-1/ input type=checkbox name=selectedroles value=ROLE_USER id=selectedroles-2 checked=checked/ input type=checkbox name=selectedroles value=ROLE_UBER id=selectedroles-3/ I don't see how you'd get a map out of that. You could get a String[] easily, which would be the ROLE_ values that were checked... The final clue! I changed my jsp to; s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ which gives me a much more sensible looking Html representation: input type=checkbox name=selectedroles value=ROLE_ADMIN id=selectedroles-1/ label for=selectedroles-1 class=checkboxLabelAdminstrator/label input type=checkbox name=selectedroles value=ROLE_USER id=selectedroles-2 checked=checked/ label for=selectedroles-2 class=checkboxLabelDiagnostics/label input type=checkbox name=selectedroles value=ROLE_UBER id=selectedroles-3/ label for=selectedroles-3 class=checkboxLabelUnrestricted/label input type=hidden id=__multiselect_checkbox_selectedroles name=__multiselect_selectedroles value= / Now when I submit the form, after changing the form method to GET so I can look at what is submitted with HttpHeaders (why I never thought of that before?) and I see that checkbox?selectedroles=ROLE_ADMINselectedroles=ROLE_USERselectedroles=ROLE_UBER__multiselect_selectedroles= is sent. I saw an exception being thrown No such method for setSelectedRoles(String) and the message Invalid field value for field selectedRoles displayed in the web-page, which must be coming from the checkbox handling routines as it certainly isn't coming from me. So I changed the method setSelectedRoles(MapString,String selectedRoles) to setSelectedRoles(String selectedRoles) and stuck the debugger on it, and what comes back is, as you suspected all along, a string value that contains a comma separated list of the selected values ie ROLE_ADMIN,ROLE_USER,ROLE_UBER which I can easily split shove back into the map of selected Roles. Phew! I would never have worked that one out without your help and I certainly wouldn't have worked it out from the available documentation. Either checkboxlist will not return a map under any circumstances, in which case the documentation should say so, or there is a way of forcing the name attribute to evaluate to something that Struts would interpret as a map entry that I haven't worked out yet. Thanks a million Regards -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28457393.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
Em 05-05-2010 07:57, RogerV escreveu: So if it's looking for a string, let's make sure you're giving it one, and not the .toString of an empty map that it got from your prepare method: s:checkboxlist name=%{'selectedroles'} list=%{availableroles} value=%{preselectedroles}/ I must admit I don't understand what you expect this to submit, or how that should become a map -- there are only one set of values, not pairs...Even if you get this to render the html I'm guessing that you expect: input type=checkbox name=selectedroles value=ROLE_ADMIN id=selectedroles-1/ input type=checkbox name=selectedroles value=ROLE_USER id=selectedroles-2 checked=checked/ input type=checkbox name=selectedroles value=ROLE_UBER id=selectedroles-3/ I don't see how you'd get a map out of that. You could get a String[] easily, which would be the ROLE_ values that were checked... The final clue! I changed my jsp to; s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ which gives me a much more sensible looking Html representation: input type=checkbox name=selectedroles value=ROLE_ADMIN id=selectedroles-1/ label for=selectedroles-1 class=checkboxLabelAdminstrator/label input type=checkbox name=selectedroles value=ROLE_USER id=selectedroles-2 checked=checked/ label for=selectedroles-2 class=checkboxLabelDiagnostics/label input type=checkbox name=selectedroles value=ROLE_UBER id=selectedroles-3/ label for=selectedroles-3 class=checkboxLabelUnrestricted/label input type=hidden id=__multiselect_checkbox_selectedroles name=__multiselect_selectedroles value= / Now when I submit the form, after changing the form method to GET so I can look at what is submitted with HttpHeaders (why I never thought of that before?) and I see that checkbox?selectedroles=ROLE_ADMINselectedroles=ROLE_USERselectedroles=ROLE_UBER__multiselect_selectedroles= is sent. I saw an exception being thrown No such method for setSelectedRoles(String) and the message Invalid field value for field selectedRoles displayed in the web-page, which must be coming from the checkbox handling routines as it certainly isn't coming from me. So I changed the method setSelectedRoles(MapString,String selectedRoles) to setSelectedRoles(String selectedRoles) and stuck the debugger on it, and what comes back is, as you suspected all along, a string value that contains a comma separated list of the selected values ie ROLE_ADMIN,ROLE_USER,ROLE_UBER which I can easily split shove back into the map of selected Roles. Phew! I would never have worked that one out without your help and I certainly wouldn't have worked it out from the available documentation. Either checkboxlist will not return a map under any circumstances, in which case the documentation should say so, or there is a way of forcing the name attribute to evaluate to something that Struts would interpret as a map entry that I haven't worked out yet. Thanks a million Regards Roger, you can use a list as setSelectedRoles(ListString selectedRoles) that will get filled with multiple Strings, this way you can iterate it easily without having to split the comma separated string. Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
Alex Rodriguez Lopez wrote: Roger, you can use a list as setSelectedRoles(ListString selectedRoles) that will get filled with multiple Strings, this way you can iterate it easily without having to split the comma separated string. Yes, you're absolutely correct. Struts will auto-translate a String of comma seperated values into a ListString which tidies things up a bit. Thanks -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28459108.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
On 5/5/10 2:57 AM, RogerV wrote: The final clue! I changed my jsp to; s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ checkbox?selectedroles=ROLE_ADMINselectedroles=ROLE_USERselectedroles=ROLE_UBER__multiselect_selectedroles= is sent. I saw an exception being thrown No such method for setSelectedRoles(String) and the message Very confusing that everyplace I've seen you have a lower case r in selectedroles, but here it's looking for capital r... So I changed the method setSelectedRoles(MapString,String selectedRoles) to setSelectedRoles(String selectedRoles) and stuck the debugger on it, and what comes back is, as you suspected all along, a string value that contains a comma separated list of the selected values ie ROLE_ADMIN,ROLE_USER,ROLE_UBER which I can easily split shove back into the map of selected Roles. The framework can be a bit more helpful than that -- if you make that take an array of Strings it should pre-split them up for you. I'd go through and make sure you've got your capitalization consistent everywhere, too. Phew! I would never have worked that one out without your help and I certainly wouldn't have worked it out from the available documentation. Sorry you had such difficulty. If you have any specific suggestions for the documentation, please help us improve it so that it can better help the next person... Either checkboxlist will not return a map under any circumstances, in which case the documentation should say so, or there is a way of forcing the name attribute to evaluate to something that Struts would interpret as a map entry that I haven't worked out yet. The tags are really only a server output thing -- is there someplace it appears to say how the results will come back? Documentation for that should be wherever the params interceptor is documented. Having that generate a map would require pairs of linked data coming in with the request, and I can't think of how that'd happen with standard html tags... -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
DNewfield wrote: Sorry you had such difficulty. If you have any specific suggestions for the documentation, please help us improve it so that it can better help the next person... I'd be happy to contribute my sample .jsp and action.java code that will illustrate how to get the s:checkboxlist tag working with map backed parameters if you think that would help, and you'd mention where you'd like it sent. Longer term I would like to see something like the showcase for the JQuery plugin that shows working examples and source code for all the tags. The struts showcase.war doesn't use s:checkboxlist at all! The irony of it all is that I only went with a map originally as I wanted to present user-friendly name for ROLE_USER etc. If I'd seen the recent thread http://old.nabble.com/s%3Aselect-help-td28443569.html before I'd started I might have avoided the pain altogether Thanks again Dale -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28461295.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
On 5/5/10 9:58 AM, RogerV wrote: I'd be happy to contribute I'd think the best place is: https://cwiki.apache.org/confluence/display/WW/Struts+2+Form+Tags I forget what hoops you have to jump through to get a working wiki account...if it doesn't just work when you try to register you might need to file a CLA with someone at apache...or you might just be able to add a comment anonymously...not sure. See if https://cwiki.apache.org/confluence/display/WW/Struts+2+Form+Tags?showComments=trueshowCommentArea=true#addcomment works. The irony of it all is that I only went with a map originally as I wanted to present user-friendly name for ROLE_USER etc. Yes--although you should suspect pretty much any value provided by the user, so you want to output the name and key, but upon submission only expect the key and do a lookup based on that. Thanks again Dale Sure! Best way to pay struts back is to help us with the documentation, and/or stay subscribed to this list so that you might be able to help someone else over the same hurdles that you've already cleared. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
On 5/3/10 2:54 AM, RogerV wrote: s:form s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ s:submit type=button label=Add/ /s:form So what html does this generate for the client to render/submit? If you set the form action to be GET it's even easier to see what it is submitting. Once you know it's submitting the right set of values, then you can focus on where those values go. This appears in your prepare selectedroles = new HashMapString,String(); So if you have params then prepare in your interceptor stack you'll drop the values collected in params on the floor. (If you have params prepare params, it should come back.) I'm not sure how the named values get submitted or how those would get converted into a map, so I wonder if this is ever called: (but I admit I'm a bit weak on the conversion process) public void setSelectedroles(MapString, String selectedroles) { this.selectedroles = selectedroles; } -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
DNewfield wrote: On 5/3/10 2:54 AM, RogerV wrote: s:form s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ s:submit type=button label=Add/ /s:form So what html does this generate for the client to render/submit? The rendering is a bit odd, which makes me feel I'm still missing something. tr td class=tdLabel/td td input type=checkbox name={} value=ROLE_ADMIN id={}-1/ label for={}-1 class=checkboxLabelAdminstrator/label input type=checkbox name={} value=ROLE_USER id={}-2 checked=checked/ label for={}-2 class=checkboxLabelDiagnostics/label input type=checkbox name={} value=ROLE_UBER id={}-3/ label for={}-3 class=checkboxLabelUnrestricted/label input type=hidden id=__multiselect_cbox name=__multiselect_{} value= / /td /tr If you set the form action to be GET it's even easier to see what it is submitting. Once you know it's submitting the right set of values, then you can focus on where those values go. This appears in your prepare selectedroles = new HashMapString,String(); So if you have params then prepare in your interceptor stack you'll drop the values collected in params on the floor. (If you have params prepare params, it should come back.) I'm using the params,prepare,params stack. I'm not sure how the named values get submitted or how those would get converted into a map, so I wonder if this is ever called: (but I admit I'm a bit weak on the conversion process) public void setSelectedroles(MapString, String selectedroles) { this.selectedroles = selectedroles; } -Dale -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28447736.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
On 5/4/10 10:08 AM, RogerV wrote: s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ input type=checkbox name={} value=ROLE_ADMIN id={}-1/ input type=checkbox name={} value=ROLE_USER id={}-2 checked=checked/ input type=checkbox name={} value=ROLE_UBER id={}-3/ The rendering is a bit odd, which makes me feel I'm still missing something. Due to the fact that there are three checkboxes with the right values and the right pre-selection, we know that the list attribute and the value attribute of the tag are working as desired. The name clearly isn't working. I've never used a checkboxlist, and I'm unclear as to how the values are aggregated on submission into the map you desire, but this brief documentation seems to jive with my understanding that name is usually just that--the name the input tag will use to submit the field to the server: name false false String The name to set for element So if it's looking for a string, let's make sure you're giving it one, and not the .toString of an empty map that it got from your prepare method: s:checkboxlist name=%{'selectedroles'} list=%{availableroles} value=%{preselectedroles}/ I must admit I don't understand what you expect this to submit, or how that should become a map -- there are only one set of values, not pairs...Even if you get this to render the html I'm guessing that you expect: input type=checkbox name=selectedroles value=ROLE_ADMIN id=selectedroles-1/ input type=checkbox name=selectedroles value=ROLE_USER id=selectedroles-2 checked=checked/ input type=checkbox name=selectedroles value=ROLE_UBER id=selectedroles-3/ I don't see how you'd get a map out of that. You could get a String[] easily, which would be the ROLE_ values that were checked... -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
Usually the error message you listed means the OGNL expression you provided for some argument did not evaluate correctly, thus some required piece of information is not available. Please post your tag usage again and I'll take a look. It's amazing what a calming effect a weekend and a few beers can have. In preparing a simplified version of what I was trying to do - everything clicked into place and at least I've got the checkboxlist displaying now. I still can't get the selected values back into my action though - the map selectedroles remains empty. I do have the checkbox interceptor configured. This is what I've got; ?xml version=1.0 encoding=ISO-8859-1 ? %@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1% %@ taglib prefix=s uri=/struts-tags % !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html head/head body s:form s:checkboxlist name=selectedroles list=%{availableroles} value=%{preselectedroles}/ s:submit type=button label=Add/ /s:form /body /html public class Checkbox extends ActionSupport implements Preparable { /** * */ private MapString,String availableroles; private MapString,String selectedroles; private MapString,String preselectedroles; public String execute() { return SUCCESS; } @Override public void prepare() throws Exception { availableroles = new HashMapString,String(); availableroles.put(ROLE_USER, Diagnostics); availableroles.put(ROLE_ADMIN, Adminstrator); availableroles.put(ROLE_UBER, Unrestricted); preselectedroles = new HashMapString,String(); preselectedroles.put(ROLE_USER, Diagnostics); selectedroles = new HashMapString,String(); } public MapString, String getAvailableroles() { return availableroles; } public void setAvailableroles(MapString, String availableroles) { this.availableroles = availableroles; } public MapString, String getSelectedroles() { return selectedroles; } public void setSelectedroles(MapString, String selectedroles) { this.selectedroles = selectedroles; } public MapString, String getPreselectedroles() { return preselectedroles; } public void setPreselectedroles(MapString, String preselectedroles) { this.preselectedroles = preselectedroles; } } Regards -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28432059.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
Could you post the Action code and JSP tanks! SALUDOS!! Mario HIDALGO Java EE Consultant | Risk IT ___ Phone 1. (722) 277 ext. 783042 Phone 2. (55) 5721 opción 3 , ext. 783042 Mobile. 0447223547727 Email. mario.hida...@hsbc.com.mx Internet.HSBC México ___ RogerV roger.var...@googlemail.com 30 Apr 2010 09:43 AM Mail Size: 7136 Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject Where is the documentation for Struts tags Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag which I still haven't been able to get working. Earlier today, I started trying to get the checkboxlist tag to work with a mapString,String and I'm still failing miserably. In both cases I get the infamous tag 'checkboxlist', field 'list', name 'roles': The requested list key 'availableroles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} tag 'checkboxlist', field 'list', name 'roles': The requested list key 'availableroles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] style of error message when I fire up my action. Googling suggest that from the number of recent posts on StackOverflow and Java Ranch for example, I'm not the only one frustrated with this. When the struts tag reference page for checkboxlist gives as its only example s:checkboxlist name=foo list=bar/ and neither pages give any indication on how these tags interact with the action code, I begin to feel that this is all starting to be more trouble than it's worth. Someone, somewhere must know of a url where this is all explained with crystal clarity with useful code examples - I just can't find it at the moment. Yours in desperation -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28413026.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org This email may contain confidential information, and is intended only for the named recipient and may be privileged. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named recipient, please notify us immediately and permanently destroy this email and all copies of it. Internet email is not private, secure, or reliable. No member of the HSBC Group is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author, and unless clearly indicated otherwise in writing, are not endorsed by any member of the HSBC group. “Este correo electrónico puede contener información confidencial, sólo está dirigida al destinatario del mismo, la información puede ser privilegiada. Está prohibido que cualquier persona distinta al destinatario copie o distribuya este correo. Si usted no es el destinatario, por favor notifíque esto de inmediato y destruya el correo, lo mismo que todas las copias que existan del mismo. Los correos electrónicos en internet, no son privados, seguros ni confiables. Ningún miembro del Grupo HSBC será responsable de los errores u omisiones en el contenido o transmisión de este correo electrónico. Cualquier opinión contenida en este correo es responsabilidad única y exclusiva del autor del mismo y, a menos que lo contrario se indique claramente y por escrito, no está respaldado por ningún miembro del Grupo HSBC”. This email may contain confidential information, and is intended only for the named recipient and may be privileged. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named recipient, please notify us immediately and permanently destroy this email and all copies of it. Internet email is not private, secure, or reliable. No member of the HSBC Group is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author, and unless clearly indicated otherwise in writing, are not endorsed by any member of the HSBC group. “Este correo electrónico puede contener información confidencial, sólo está dirigida al destinatario del mismo, la información puede ser privilegiada. Está prohibido que cualquier persona distinta al destinatario copie o distribuya este correo. Si usted no es el destinatario, por favor notifíque esto de inmediato y destruya el correo, lo mismo que todas las
Re: Where is the documentation for Struts tags ....
On 4/30/10 10:43 AM, RogerV wrote: Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag http://struts.apache.org/2.x/docs/optiontransferselect.html But there appears to be a bug with the snippets right now... ...so instead look at http://struts.apache.org/2.1.8/docs/optiontransferselect.html Usually the error message you listed means the OGNL expression you provided for some argument did not evaluate correctly, thus some required piece of information is not available. Please post your tag usage again and I'll take a look. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
http://struts.apache.org/2.0.14/docs/tag-reference.html On Fri, Apr 30, 2010 at 8:29 AM, Dale Newfield d...@newfield.org wrote: On 4/30/10 10:43 AM, RogerV wrote: Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag http://struts.apache.org/2.x/docs/optiontransferselect.html But there appears to be a bug with the snippets right now... ...so instead look at http://struts.apache.org/2.1.8/docs/optiontransferselect.html Usually the error message you listed means the OGNL expression you provided for some argument did not evaluate correctly, thus some required piece of information is not available. Please post your tag usage again and I'll take a look. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org