Re: Java templates s:checkboxlist tag and the significance of parameters.nameValue
Thank you Mauricio. I appreciate your help. If that is a bug though, is there a possibility of using Java templetes engine for some tags or pages and FM engine for others? On Sep 9, 2011 5:21 PM, Maurizio Cucchiara [via Struts] ml-node+s1045723n4788357...@n5.nabble.com wrote: JT and FMT should behave at the same way. So my first guess is that it's a JT bug Unfortunately I cannot say more from my tablet, I will take a deeper look ASAP. Maurizio Cucchiara Il giorno 10/set/2011 00.59, vatermann_shoevarek vaterm...@gmail.com ha scritto: I am considering switching my application to using Java theme provided by Java templates plugin. The only problem I have is the s:checkboxlist tag. My solution uses s:checkboxlist with name of the Long type property of element in list passed to list attribute as a listKey and collection of Long instances as a selected keys in value attribute. After conversion generated drop down does not check options correctly. I have looked into FreeMarker template and CheckboxListHandler implementations and the difference I see is that where the FM probably compares current option key with parameters.nameValue using plain equal() method call, the Java templates handler implementation assumes that the nameValue is a boolean. That obviously is not the case so none of the options are checked. So here are my questions. What should I set to value attribute of that tag and how parameters.nameValue is managed? That property is not exposed as a tag attribute?? Thanks in advance for any help. Regards, Andrzej -- View this message in context: http://struts.1045723.n5.nabble.com/Java-templates-s-checkboxlist-tag-and-the-significance-of-parameters-nameValue-tp4788197p4788197.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 ___ If you reply to this email, your message will be added to the discussion below: http://struts.1045723.n5.nabble.com/Java-templates-s-checkboxlist-tag-and-the-significance-of-parameters-nameValue-tp4788197p4788357.html To unsubscribe from Java templates s:checkboxlist tag and the significance of parameters.nameValue, visit http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4788197code=dmF0ZXJtYW5uQGdtYWlsLmNvbXw0Nzg4MTk3fDE4MTI0NTM1Njk= -- View this message in context: http://struts.1045723.n5.nabble.com/Java-templates-s-checkboxlist-tag-and-the-significance-of-parameters-nameValue-tp4788197p4789450.html Sent from the Struts - User mailing list archive at Nabble.com.
Java templates s:checkboxlist tag and the significance of parameters.nameValue
I am considering switching my application to using Java theme provided by Java templates plugin. The only problem I have is the s:checkboxlist tag. My solution uses s:checkboxlist with name of the Long type property of element in list passed to list attribute as a listKey and collection of Long instances as a selected keys in value attribute. After conversion generated drop down does not check options correctly. I have looked into FreeMarker template and CheckboxListHandler implementations and the difference I see is that where the FM probably compares current option key with parameters.nameValue using plain equal() method call, the Java templates handler implementation assumes that the nameValue is a boolean. That obviously is not the case so none of the options are checked. So here are my questions. What should I set to value attribute of that tag and how parameters.nameValue is managed? That property is not exposed as a tag attribute?? Thanks in advance for any help. Regards, Andrzej -- View this message in context: http://struts.1045723.n5.nabble.com/Java-templates-s-checkboxlist-tag-and-the-significance-of-parameters-nameValue-tp4788197p4788197.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: Java templates s:checkboxlist tag and the significance of parameters.nameValue
JT and FMT should behave at the same way. So my first guess is that it's a JT bug Unfortunately I cannot say more from my tablet, I will take a deeper look ASAP. Maurizio Cucchiara Il giorno 10/set/2011 00.59, vatermann_shoevarek vaterm...@gmail.com ha scritto: I am considering switching my application to using Java theme provided by Java templates plugin. The only problem I have is the s:checkboxlist tag. My solution uses s:checkboxlist with name of the Long type property of element in list passed to list attribute as a listKey and collection of Long instances as a selected keys in value attribute. After conversion generated drop down does not check options correctly. I have looked into FreeMarker template and CheckboxListHandler implementations and the difference I see is that where the FM probably compares current option key with parameters.nameValue using plain equal() method call, the Java templates handler implementation assumes that the nameValue is a boolean. That obviously is not the case so none of the options are checked. So here are my questions. What should I set to value attribute of that tag and how parameters.nameValue is managed? That property is not exposed as a tag attribute?? Thanks in advance for any help. Regards, Andrzej -- View this message in context: http://struts.1045723.n5.nabble.com/Java-templates-s-checkboxlist-tag-and-the-significance-of-parameters-nameValue-tp4788197p4788197.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: Problem with s:checkboxlist, FreeMarker template Error
Hello guys, I'm sorry i didn's post any code of my problem, I already solved it, the name attribute was missing in my example. I went with key attribute and is already working, thanks anyway! -- Manolo Pájaro Santander Ingeniero de Sistemas VIII Semestre (Actual) Promoviendo el Software Libre CUSOL-UAC Linux Registered User # 522026
Problem with s:checkboxlist, FreeMarker template Error
Hello list!! I'm having a problema with this tag, I don't know what to do :( I hope you guys could help me. As here says http://struts.apache.org/2.2.3/docs/checkboxlist.html I can use a Map object in the list attribute of a checkboxlist, When i go for it I got this FreeMarker template error: FreeMarker template error! Expression parameters.name is undefined on line 38, column 32 in template/simple/checkboxlist.ftl. The problematic instruction: -- == ${parameters.name?html} [on line 38, column 30 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlist.ftl] -- Java backtrace for programmers: -- freemarker.core.InvalidReferenceException: Expression parameters.name is undefined on line 38, column 32 in template/simple/checkboxlist.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.Environment.visit(Environment.java:299) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.IfBlock.accept(IfBlock.java:82) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.Environment.include(Environment.java:1483) at freemarker.core.Include.accept(Include.java:169) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.Environment.process(Environment.java:190) at freemarker.template.Template.process(Template.java:237) at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:157) at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559) at org.apache.struts2.components.UIBean.end(UIBean.java:513) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42) at org.apache.jsp.jsp.GuardarAlumnoForm_jsp._jspx_met Even weirder, when I use a List object (because, i don't know, maybe List would work), I also get the same error! I don't know if this is a bug or I am doing something wrong. In the action class I define a MapInteger,String objected implemented as HashMap, and ListString as ArrayList, I dont' even know what freemarker is :( Thank you for your help -- Manolo Pájaro Santander Ingeniero de Sistemas VIII Semestre (Actual) Promoviendo el Software Libre CUSOL-UAC Linux Registered User # 522026
s:checkboxlist and the CheckBox Interceptor
The documentation says that the checkbox interceptor Looks for a hidden identification field that specifies the original value of the checkbox. If the checkbox isn't submitted, insert it into the parameters as if it was with the value of 'false'. Should the interceptor work with s:checkboxlist or does it only work with s:checkbox. All I'm getting back from the s:checkboxlist is a list of selected checkboxes, there's no indication of any that are unselected. Given the trouble I've been having with the s:checkboxlist tag recently I thought I'd ask before I dive in. Regards -- View this message in context: http://old.nabble.com/%3Cs%3Acheckboxlist%3E-and-the-CheckBox-Interceptor-tp28470565p28470565.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: s:checkboxlist and the CheckBox Interceptor
On 5/6/10 4:15 AM, RogerV wrote: The documentation says that the checkbox interceptor Looks for a hidden identification field that specifies the original value of the checkbox. If the checkbox isn't submitted, insert it into the parameters as if it was with the value of 'false'. So let's think about how that works: If a form includes input type=checkbox name=foo value=true / then the browser either includes foo=true as a parameter or does not. The checkbox tag also causes the form to include input type=hidden name=__checkbox_foo value=true / . When the interceptor runs, if it sees a value for __checkbox_foo but none for foo then it knows the checkbox was not checked and can add as a request parameter the field foo with the appropriate value for a non-checked checkbox. Should the interceptor work withs:checkboxlist or does it only work with s:checkbox. All I'm getting back from thes:checkboxlist is a list of selected checkboxes, there's no indication of any that are unselected. When you're including in the form a bunch of checkboxes with the same name attribute, the browser will submit those that were checked and not submit anything for those that were not. Since they all get submitted with the same name, I can think of no simple way for the server to distinguish between them, or thus detect which checkboxes were not submitted (which would then enable the interceptor to decide which hidden fields need to be introduced into the parameter set. Given the trouble I've been having with thes:checkboxlist tag recently I thought I'd ask before I dive in. I could be wrong about this -- I've not used the checkboxlist tag myself, and have not read any documentation before writing this response -- I'm just providing my gut reaction on how the underlying html form mechanisms mean the same checkbox solution would not work easily if the checkbox's name were not unique. Maybe another solution has been figured out and implemented already. For example, if there were a set of hidden fields corresponding to the checkboxes, it might be possible to figure out which of those values were not included in those submitted by the checkboxes, and set some other request parameters to match (so you could end up with a list of checked values (setFoo(ListString)) and a list of unchecked values (setNotFoo(ListString))). I'd look in the documentation, the .ftl files implementing the checkboxlist tag to see if there are any useful hidden fields included in the form, and the interceptor code to see exactly what it does (especially when multiple request parameters have the same name). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
s:checkboxlist help
s:checkboxlist list=#{0:'',1:'',2:''} name=user label=%{getText('com.upasana.type.'+toString())}/s:checkboxlist But the key value is not passed to getText() The idea is to just initialize the keys in the checkboxlist and fetch the corresponding display text from .properties file Thanks in advance
Re: s:checkboxlist help
Hi, the label attribute is only used to render the label of the group of checkboxes. It is not used in an iterative way. In order to access to your .properties file, you have to build your list in your action then give it in list attribute. Regards Sébastien Le 05/05/2010 10:56, Upasana Sharma a écrit : s:checkboxlist list=#{0:'',1:'',2:''} name=user label=%{getText('com.upasana.type.'+toString())}/s:checkboxlist But the key value is not passed to getText() The idea is to just initialize the keys in the checkboxlist and fetch the corresponding display text from .properties file Thanks in advance - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:checkboxlist help
thanks for the response the issue is solved as s:checkboxlist list=#{0:'',1:'',2:'',3:'',4:''} name=user listValue=%{getText('com.upasana..type.'+ key.toString())}/s:checkboxlist On Wed, May 5, 2010 at 2:41 PM, Sébastien Domergue sebastien.domer...@c-s.fr wrote: Hi, the label attribute is only used to render the label of the group of checkboxes. It is not used in an iterative way. In order to access to your .properties file, you have to build your list in your action then give it in list attribute. Regards Sébastien Le 05/05/2010 10:56, Upasana Sharma a écrit : s:checkboxlist list=#{0:'',1:'',2:''} name=user label=%{getText('com.upasana.type.'+toString())}/s:checkboxlist But the key value is not passed to getText() The idea is to just initialize the keys in the checkboxlist and fetch the corresponding display text from .properties file Thanks in advance - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Thanks and Regards Upasana Sharma
Re: s:checkboxlist or s:checkbox
tks for both of u try to help me s:iterator value=beds status=st s:property value=bed_id/ /s:iterator the above works, and print the value of bed_id but, the following still not works s:iterator value=beds status=st var=curBed s:checkbox name=%{'bed[' + (st.count-1) + ']'} alue=#curBed.bed_id/s:checkbox /s:iterator and running result complain the var tag please advise, tks in advance john --- On Fri, 4/10/09, Dave Newton newton.d...@yahoo.com wrote: From: Dave Newton newton.d...@yahoo.com Subject: Re: s:checkboxlist or s:checkbox To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 10, 2009, 6:28 PM Wes Wannemacher wrote: Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. Putting in an index only matters if order is important (and you don't trust the browser to submit in order); if a page has multiple variables of the same name their values will be put into an array or collection action property. For a checkbox w/ a true/false value probably need either an index or to use a map-based property. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:checkboxlist or s:checkbox
tks very much, it works after change var to id. Also, have further question need to bother you similar to it same bean class public class Bed { private String bed_id; public String getBed_id() {return bed_id;} public void setBed_id(String bed_id) { this.bed_id=bed_id; } } same action class ... private ArrayListBed beds; public String execute() throws Exception { beds=service.Beds(); return SUCCESS; } public void setBeds(ArrayListBed beds){ this.beds = beds; } public ArrayListBed getBeds() { return beds; } almost same jsp file s:iterator value=beds status=st s:property value=bed_id/ /s:iterator s:select label=Bed ID name=bed_id headerKey=1 headerValue=Please Select Bed# list=beds/ /* the problem */ the output is 1 2 3 4 ...@188d92e ...@16a5bcb b...@1b08cf3 @1f5d699 my question is that why s:select list print object but value, is because i defined ArrayListBed ? what is the correct way to fetch value out as s:iterators:property value=bed_id/ did tks in advance again --- On Sat, 4/11/09, Wes Wannemacher w...@wantii.com wrote: From: Wes Wannemacher w...@wantii.com Subject: Re: s:checkboxlist or s:checkbox To: john lee sh_thorn_b...@yahoo.com Date: Saturday, April 11, 2009, 11:53 AM Try to use id attribute instead of var -W On 4/11/09, john lee sh_thorn_b...@yahoo.com wrote: tks for both of u try to help me s:iterator value=beds status=st s:property value=bed_id/ /s:iterator the above works, and print the value of bed_id but, the following still not works s:iterator value=beds status=st var=curBed s:checkbox name=%{'bed[' + (st.count-1) + ']'} alue=#curBed.bed_id/s:checkbox /s:iterator and running result complain the var tag please advise, tks in advance john --- On Fri, 4/10/09, Dave Newton newton.d...@yahoo.com wrote: From: Dave Newton newton.d...@yahoo.com Subject: Re: s:checkboxlist or s:checkbox To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 10, 2009, 6:28 PM Wes Wannemacher wrote: Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. Putting in an index only matters if order is important (and you don't trust the browser to submit in order); if a page has multiple variables of the same name their values will be put into an array or collection action property. For a checkbox w/ a true/false value probably need either an index or to use a map-based property. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Sent from my mobile device Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher
s:checkboxlist or s:checkbox
I defined an entity java. public class Bed { private String bed_id; public String getBed_id() {return bed_id;} public void setBed_id(String bed_id) { this.bed_id=bed_id; } } in action file, i did the following, public class Analysis_input extends ActionSupport { private ArrayListBed beds; public String execute() throws Exception { / * initialized service...and it is database connection */ beds=service.Beds(); ActionContext.getContext().getSession().put(Beds,beds); return SUCCESS; } public void setBeds(ArrayListBed beds){ this.beds = beds; } public ArrayListBed getBeds() { return beds; } } in jsp file, i did s:checkboxlist name=beds list=beds / but received the error FreeMarker template error! Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlist.ftl] if i change the jsp file to the following s:iterator value=beds status=st s:checkbox name=beds value=bed_id/s:checkboxbr /s:iterator but receive the new error !--StartFragment--Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: -- == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlistany expert can give me the advise? i am new to struts 2tks in advancejohn
Re: s:checkboxlist or s:checkbox
I'm jumping in a bit late, but I'll add a few observations. I don't think that execute is the place where you want to initialize your service and populate the beds list... You're better off implementing Preparable and initializing the list there. Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. -Wes On Friday 10 April 2009 01:59:42 john lee wrote: I defined an entity java. public class Bed { private String bed_id; public String getBed_id() {return bed_id;} public void setBed_id(String bed_id) { this.bed_id=bed_id; } } in action file, i did the following, public class Analysis_input extends ActionSupport { private ArrayListBed beds; public String execute() throws Exception { / * initialized service...and it is database connection */ beds=service.Beds(); ActionContext.getContext().getSession().put(Beds,beds); return SUCCESS; } public void setBeds(ArrayListBed beds){this.beds = beds;} public ArrayListBed getBeds() { return beds;} } in jsp file, i did s:checkboxlist name=beds list=beds / but received the error FreeMarker template error! Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlist.ftl] if i change the jsp file to the following s:iterator value=beds status=st s:checkbox name=beds value=bed_id/s:checkboxbr /s:iterator but receive the new error !--StartFragment--Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: -- == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlistany expert can give me the advise? i am new to struts 2tks in advancejohn -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:checkboxlist or s:checkbox
tks for your quick response. the reason i initialize there is because try to get fresh list from database. second, as your suggest, i need to change the name, but how? tks in advance again john --- On Fri, 4/10/09, Wes Wannemacher w...@wantii.com wrote: From: Wes Wannemacher w...@wantii.com Subject: Re: s:checkboxlist or s:checkbox To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 10, 2009, 1:09 AM I'm jumping in a bit late, but I'll add a few observations. I don't think that execute is the place where you want to initialize your service and populate the beds list... You're better off implementing Preparable and initializing the list there. Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. -Wes On Friday 10 April 2009 01:59:42 john lee wrote: I defined an entity java. public class Bed { private String bed_id; public String getBed_id() {return bed_id;} public void setBed_id(String bed_id) { this.bed_id=bed_id; } } in action file, i did the following, public class Analysis_input extends ActionSupport { private ArrayListBed beds; public String execute() throws Exception { / * initialized service...and it is database connection */ beds=service.Beds(); ActionContext.getContext().getSession().put(Beds,beds); return SUCCESS; } public void setBeds(ArrayListBed beds){ this.beds = beds; } public ArrayListBed getBeds() { return beds; } } in jsp file, i did s:checkboxlist name=beds list=beds / but received the error FreeMarker template error! Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlist.ftl] if i change the jsp file to the following s:iterator value=beds status=st s:checkbox name=beds value=bed_id/s:checkboxbr /s:iterator but receive the new error !--StartFragment--Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: -- == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlistany expert can give me the advise? i am new to struts 2tks in advancejohn -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:checkboxlist or s:checkbox
On Friday 10 April 2009 02:14:22 john lee wrote: tks for your quick response. the reason i initialize there is because try to get fresh list from database. Preparable will run per invocation, just like execute runs once per invocation. The difference is that execute is likely to run after the view has been rendered. Check this page - http://struts.apache.org/2.x/docs/prepare-interceptor.html second, as your suggest, i need to change the name, but how? Really, implementing Preparable and moving the initialization logic to a prepare method is your best option. But, what you have to do to make your checkboxes unique is add some OGNL like this - s:iterator value=beds status=st var=curBed s:checkbox name=%{'bed[' + (st.count -1) + ']' value=#curBed.bed_id/s:checkbox /s:iterator Now, that code is completely untested and the status object's count member is 1-based, not zero-based as you'll need since you're iterating an ArrayList, that's why there is some math in there. I can't remember if you can do it that way or if you'll just end up with string concatenations... but you get the idea. You could also get done and find the object uninitialized since your logic for loading up the arraylist is done in the execute method. -Wes tks in advance again john --- On Fri, 4/10/09, Wes Wannemacher w...@wantii.com wrote: From: Wes Wannemacher w...@wantii.com Subject: Re: s:checkboxlist or s:checkbox To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 10, 2009, 1:09 AM I'm jumping in a bit late, but I'll add a few observations. I don't think that execute is the place where you want to initialize your service and populate the beds list... You're better off implementing Preparable and initializing the list there. Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. -Wes On Friday 10 April 2009 01:59:42 john lee wrote: I defined an entity java. public class Bed { private String bed_id; public String getBed_id() {return bed_id;} public void setBed_id(String bed_id) { this.bed_id=bed_id; } } in action file, i did the following, public class Analysis_input extends ActionSupport { private ArrayListBed beds; public String execute() throws Exception { / * initialized service...and it is database connection */ beds=service.Beds(); ActionContext.getContext().getSession().put(Beds,beds); return SUCCESS; } public void setBeds(ArrayListBed beds){this.beds = beds; } public ArrayListBed getBeds() { return beds;} } in jsp file, i did s:checkboxlist name=beds list=beds / but received the error FreeMarker template error! Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlist.ftl] if i change the jsp file to the following s:iterator value=beds status=st s:checkbox name=beds value=bed_id/s:checkboxbr /s:iterator but receive the new error !--StartFragment--Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: -- == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlistany expert can give me the advise? i am new to struts 2tks in advancejohn -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:checkboxlist or s:checkbox
tks for your great advise, i run the code, but receive the following error /Analysis_input.jsp(17,12) Attribute var invalid for tag iterator according to TLD i check the syntax, then i put extra } inside the tag as the following then i put extra '}' inside s:checkbox name=%{'bed[' + (st.count -1) + ']'}' value=#curBed.bed_id/s:checkbox and run again, but receive the same error, please advise. tks again john --- On Fri, 4/10/09, Wes Wannemacher w...@wantii.com wrote: From: Wes Wannemacher w...@wantii.com Subject: Re: s:checkboxlist or s:checkbox To: john lee sh_thorn_b...@yahoo.com Cc: Struts Users Mailing List user@struts.apache.org Date: Friday, April 10, 2009, 1:26 AM On Friday 10 April 2009 02:14:22 john lee wrote: tks for your quick response. the reason i initialize there is because try to get fresh list from database. Preparable will run per invocation, just like execute runs once per invocation. The difference is that execute is likely to run after the view has been rendered. Check this page - http://struts.apache.org/2.x/docs/prepare-interceptor.html second, as your suggest, i need to change the name, but how? Really, implementing Preparable and moving the initialization logic to a prepare method is your best option. But, what you have to do to make your checkboxes unique is add some OGNL like this - s:iterator value=beds status=st var=curBed s:checkbox name=%{'bed[' + (st.count -1) + ']' value=#curBed.bed_id/s:checkbox /s:iterator Now, that code is completely untested and the status object's count member is 1-based, not zero-based as you'll need since you're iterating an ArrayList, that's why there is some math in there. I can't remember if you can do it that way or if you'll just end up with string concatenations... but you get the idea. You could also get done and find the object uninitialized since your logic for loading up the arraylist is done in the execute method. -Wes tks in advance again john --- On Fri, 4/10/09, Wes Wannemacher w...@wantii.com wrote: From: Wes Wannemacher w...@wantii.com Subject: Re: s:checkboxlist or s:checkbox To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 10, 2009, 1:09 AM I'm jumping in a bit late, but I'll add a few observations. I don't think that execute is the place where you want to initialize your service and populate the beds list... You're better off implementing Preparable and initializing the list there. Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. -Wes On Friday 10 April 2009 01:59:42 john lee wrote: I defined an entity java. public class Bed { private String bed_id; public String getBed_id() {return bed_id;} public void setBed_id(String bed_id) { this.bed_id=bed_id; } } in action file, i did the following, public class Analysis_input extends ActionSupport { private ArrayListBed beds; public String execute() throws Exception { / * initialized service...and it is database connection */ beds=service.Beds(); ActionContext.getContext().getSession().put(Beds,beds); return SUCCESS; } public void setBeds(ArrayListBed beds){ this.beds = beds; } public ArrayListBed getBeds() { return beds; } } in jsp file, i did s:checkboxlist name=beds list=beds / but received the error FreeMarker template error! Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlist.ftl] if i change the jsp file to the following s:iterator value=beds status=st s:checkbox name=beds value=bed_id/s:checkboxbr /s:iterator but receive the new error !--StartFragment--Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: -- == assignment: itemKey=stack.findValue(parameters.listKey) [on line 28, column 13 in template/simple/checkboxlist.ftl] in user-directive s.iterator [on line 25, column 5 in template/simple/checkboxlist.ftl] in include /${parameters.templateDir}/simple/checkboxlist.ftl [on line 25, column 1 in template/xhtml/checkboxlistany expert can give me the advise? i am new
Re: s:checkboxlist or s:checkbox
Wes Wannemacher wrote: Second, when you are using the iterator and creating single checkboxes, you need to make the names unique. You are simply creating a new checkbox with the name beds over and over again. Putting in an index only matters if order is important (and you don't trust the browser to submit in order); if a page has multiple variables of the same name their values will be put into an array or collection action property. For a checkbox w/ a true/false value probably need either an index or to use a map-based property. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:checkboxlist is there a way to do checked/unchecked
i resolved this senario by replacing JSP as s:iterator value=%{contentList} input type='checkbox' name=selectedContents value='s:property value=MMSContentId/' s:property value=CheckedValue/ s:property value=MMSContentName / /input /s:iterator !-- s:checkboxlist value=CheckedValue list=%{contentList} listKey=MMSContentId listValue=MMSContentName name=selectedContents /s:checkboxlist -- -- View this message in context: http://www.nabble.com/s%3Acheckboxlist-is-there-a-way-to-do-checked-unchecked-tp22633750p22635741.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: s:checkboxlist is there a way to do checked/unchecked
i resolved this senario by replacing JSP as s:iterator value=%{contentList} input type='checkbox' name=selectedContents value='s:property value=MMSContentId/' s:property value=CheckedValue/ s:property value=MMSContentName / /input /s:iterator !-- s:checkboxlist value=CheckedValue list=%{contentList} listKey=MMSContentId listValue=MMSContentName name=selectedContents /s:checkboxlist -- -- View this message in context: http://www.nabble.com/s%3Acheckboxlist-is-there-a-way-to-do-checked-unchecked-tp22633750p22635745.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: s:checkboxlist is there a way to do checked/unchecked
i resolved this senario by replacing JSP as s:iterator value=%{contentList} input type='checkbox' name=selectedContents value='s:property value=MMSContentId/' s:property value=CheckedValue/ s:property value=MMSContentName / /input /s:iterator !-- s:checkboxlist value=CheckedValue list=%{contentList} listKey=MMSContentId listValue=MMSContentName name=selectedContents /s:checkboxlist -- -- View this message in context: http://www.nabble.com/s%3Acheckboxlist-is-there-a-way-to-do-checked-unchecked-tp22633750p22635748.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
s:radio and s:checkboxlist - how to customize listValue property.
When I use that 2 components in my form I need to set attributes listValue and listKey. That attributes as I understand require a field of a bean that is a member of collection represented by list attribute. Example: s:radio list=types name=type label=Type listValue=name listKey=id / That means: 1) there will be one radiobutton for each element of collection getTypes(). 2) Each html radiobutton will have value = getId() and label = getName() . I want to compose label from several fields of my bean. So I can't write s:radio listValue=someField / because that class doesn't have getSomeField() method. How can I do this ? -- View this message in context: http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22455829.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: s:radio and s:checkboxlist - how to customize listValue property.
The easiest (I'm not going to say best) solution is to make a fake getter on your bean. Make a getListLabel() method that composes a String from the values that you want to display in the list label, and then set the listValue to be listLabel. This is the way I've done this in the past and it works OK. It isn't ideal if you want to keep your model carefully isolated from your UI but my own designs are a little less pure than that. jk On Wed, Mar 11, 2009 at 10:05 AM, boraldo bora...@hotbox.ru wrote: When I use that 2 components in my form I need to set attributes listValue and listKey. That attributes as I understand require a field of a bean that is a member of collection represented by list attribute. Example: s:radio list=types name=type label=Type listValue=name listKey=id / That means: 1) there will be one radiobutton for each element of collection getTypes(). 2) Each html radiobutton will have value = getId() and label = getName() . I want to compose label from several fields of my bean. So I can't write s:radio listValue=someField / because that class doesn't have getSomeField() method. How can I do this ? -- View this message in context: http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22455829.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 -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com
Re: s:radio and s:checkboxlist - how to customize listValue property.
It isn't ideal if you want to keep your model carefully isolated from your UI Unfortunately it is the case, so I need another solution. Jim Kiley wrote: The easiest (I'm not going to say best) solution is to make a fake getter on your bean. Make a getListLabel() method that composes a String from the values that you want to display in the list label, and then set the listValue to be listLabel. This is the way I've done this in the past and it works OK. It isn't ideal if you want to keep your model carefully isolated from your UI but my own designs are a little less pure than that. jk On Wed, Mar 11, 2009 at 10:05 AM, boraldo bora...@hotbox.ru wrote: When I use that 2 components in my form I need to set attributes listValue and listKey. That attributes as I understand require a field of a bean that is a member of collection represented by list attribute. Example: s:radio list=types name=type label=Type listValue=name listKey=id / That means: 1) there will be one radiobutton for each element of collection getTypes(). 2) Each html radiobutton will have value = getId() and label = getName() . I want to compose label from several fields of my bean. So I can't write s:radio listValue=someField / because that class doesn't have getSomeField() method. How can I do this ? -- View this message in context: http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22455829.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 -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com -- View this message in context: http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22458070.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
s:checkboxlist
BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }Hallo, is there any way to set that all items (checkboxes) in s:checkboxlist are in their own line, one checkbox under other. Defaultly they are all on the same line and I cannot find the way how to set that each one checkbox has to have their own line :-( Thanks, Jiri
Re: s:checkboxlist
The way I solved this was to add my own theme, and change the xhtml theme's checkboxlist template to match what I wanted 'my' checkboxlist to do. Under the root of your web app, add a directory named template. Under template add a directory called myapp. Then copy checkboxlist.ftl out of the Struts jar into template/myapp, and modify it as you wish. Finally, in your JSP, do s:checkboxlist theme=myapp .../ This comes up fairly often -- I am happy to add it to the FAQ if someone can tell me how I do that. jk On Thu, Feb 26, 2009 at 5:46 AM, k...@chalu.cz wrote: BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }Hallo, is there any way to set that all items (checkboxes) in s:checkboxlist are in their own line, one checkbox under other. Defaultly they are all on the same line and I cannot find the way how to set that each one checkbox has to have their own line :-( Thanks, Jiri -- Jim Kiley Technical Consultant | Summa [p] 412.258.3346 [m] 412.445.1729 http://www.summa-tech.com
Re: s:checkboxlist
Hallo Jim, perfect, thank you Jiri Jim Kiley napsal(a): The way I solved this was to add my own theme, and change the xhtml theme's checkboxlist template to match what I wanted 'my' checkboxlist to do. Under the root of your web app, add a directory named template. Under template add a directory called myapp. Then copy checkboxlist.ftl out of the Struts jar into template/myapp, and modify it as you wish. Finally, in your JSP, do s:checkboxlist theme=myapp .../ This comes up fairly often -- I am happy to add it to the FAQ if someone can tell me how I do that. jk On Thu, Feb 26, 2009 at 5:46 AM, k...@chalu.cz mailto:k...@chalu.cz wrote: BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }Hallo, is there any way to set that all items (checkboxes) in s:checkboxlist are in their own line, one checkbox under other. Defaultly they are all on the same line and I cannot find the way how to set that each one checkbox has to have their own line :-( Thanks, Jiri -- Jim Kiley Technical Consultant | Summa [p] 412.258.3346 [m] 412.445.1729 http://www.summa-tech.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
s:radio/s:checkboxlist and primitive properties
I tried to use primitive types/arrays of primitives as name property of s:radio and s:checkboxlist. It works fine, but the state is not maintained because the ContainUtil.compare() method returns false as it compares e.g. an Integer and a Sting using Object.equals(). Is there a reason why we can't use primitives like in for example s:checkbox? I patched my own ContainUtil.compare() and it seems to work fine now - should I log a JIRA issue/RFE? Hope I haven't overlooked an existing issue/post on this! Torsten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: s:radio/s:checkboxlist and primitive properties
Sorry I just realize I didn't use the tag the right way. I had String literals in my list instead of the actual primitives/objects... Now of course it works just fine without any patching! Slowly, but I am getting there ;-) Torsten Torsten Römer schrieb: I tried to use primitive types/arrays of primitives as name property of s:radio and s:checkboxlist. It works fine, but the state is not maintained because the ContainUtil.compare() method returns false as it compares e.g. an Integer and a Sting using Object.equals(). Is there a reason why we can't use primitives like in for example s:checkbox? I patched my own ContainUtil.compare() and it seems to work fine now - should I log a JIRA issue/RFE? Hope I haven't overlooked an existing issue/post on this! Torsten - 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]
s:checkboxlist
Is there a way to pre-check boxes that meet criteria? I have 2 lists, listA is for all the checkboxes and listB is for checkboxes that will be pre-checked. s:checkboxlist label=Registration list=#allreglist.regList listKey=regId listValue=regNm name=reg.registrationList /s:checkboxlist This displays a checkbox list fine for insert. How do I get the pre-selected boxes for an update? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: s:checkboxlist
--- Hartrich, James CTR USTRANSCOM J6 wrote: Is there a way to pre-check boxes that meet criteria? I have 2 lists, listA is for all the checkboxes and listB is for checkboxes that will be pre-checked. In my app I currently have: s:checkboxlist list=tags name=tagids listKey=id listValue=name/ In the action, the tags property is the list of all possible tags. tagids holds the selected tags. In my preparation I add every selected option from tags into tagids; s:checkboxlist.../ does the rest. HTH, d. Finding fabulous fares is fun. Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains. http://farechase.yahoo.com/promo-generic-14795097 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] s:iterator and s:checkboxlist inside (using 2.0.2 trunk)
Hi, I have such properties in my action: private ArrayListExtension extensionGroups = null; private HashMapString, ArrayListExtension groupedExtensions = null; The 1st list contains only some 'Extension' elements. The 2nd map contains other lists of extensions (values) with some property (treeNo) from the parent used as the key. Then I have a JSP page with such construct somewhere in it: s:iterator value=extensionGroups b${desc}/bbr / s:checkboxlist list=groupedExtensions['${treeNo}'] listKey=name listValue=desc name=extensions labelposition=right / /s:iterator And here is a strange thing: When I start the app and run the action for the 1st time I get nice result AS EXPECTED: GROUP1 chk: extension1 chk: extension2 chk: extension3 GROUP2 chk: extension4 chk: extension5 But after reloading the page (no extra params in the url, just plain GET), the result is: chk: GROUP1 chk: GROUP2 Looks like the context of the data beaing displayed is different. But it's the same page! The same code and the same data. After restarting the app it is again the same behaviour. My debugs in the actions (getters) show that the same data is returned in all cases. What am I doing wrong? Dariusz Wojtas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] s:iterator and s:checkboxlist inside (using 2.0.2 trunk)
I have found a solution after lots of experiments. I am still not sure what caused the problems (I tried tons of variants in the JSP) but finally it started to work. No changes in the action code, only in the JSP block. It started to work after I added jstl into the game and dropped the s:iterate tag. s:set name=groups value=extensionGroups / c:forEach items=${groups} var=group b${group.desc}/bbr / s:checkboxlist list=groupedExtensions['${group.treeNo}'] listKey=name listValue=desc name=extensions labelposition=right / /c:forEach Can somebody say what caused problems in the previous code I have sent? Why did it work on the 1st invocation and failed on all other calls? Dariusz Wojtas On 12/22/06, Dariusz Wojtas [EMAIL PROTECTED] wrote: Hi, I have such properties in my action: private ArrayListExtension extensionGroups = null; private HashMapString, ArrayListExtension groupedExtensions = null; The 1st list contains only some 'Extension' elements. The 2nd map contains other lists of extensions (values) with some property (treeNo) from the parent used as the key. Then I have a JSP page with such construct somewhere in it: s:iterator value=extensionGroups b${desc}/bbr / s:checkboxlist list=groupedExtensions['${treeNo}'] listKey=name listValue=desc name=extensions labelposition=right / /s:iterator And here is a strange thing: When I start the app and run the action for the 1st time I get nice result AS EXPECTED: GROUP1 chk: extension1 chk: extension2 chk: extension3 GROUP2 chk: extension4 chk: extension5 But after reloading the page (no extra params in the url, just plain GET), the result is: chk: GROUP1 chk: GROUP2 Looks like the context of the data beaing displayed is different. But it's the same page! The same code and the same data. After restarting the app it is again the same behaviour. My debugs in the actions (getters) show that the same data is returned in all cases. What am I doing wrong? Dariusz Wojtas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]