Re: multibox not works when all checkboxes are unselected!
Thanks for this great explanations I already solved this problem and now 'm quite close to understand it! It would be great to have a sequence diagramm to see this flow submit-reset-populate-validate because knowing this flow isn't quite clear to a normal struts-user. THANKS A LOT starki78 wrote: Hi! I've a large problem with html:multibox. I've tree checkboxes. When I choose one or two or three it arrives correct at the next action! Only then all checkboxes are deselected it remembers the state of the checkboxes that was selected before! The state of the form is session in struts-config. Can you help me with this problem?? I really don't have an idea how to solve it! As Adam J. mentioned, it sounds like you're using a session-scoped bean. Try overriding (if you haven't already) the reset() method of your form bean and resetting the property: public void reset( ActionMapping mapping, HttpServletRequest request ) { this.values = new String[0]; } If you're _not_ using a session bean (and are using a request-scoped one instead), you'll _still_ want to do the above. Using this way in both cases, values from the previous request are discarded. If the web browser doesn't send any checkbox values over (because none are checked), then this.values will be an empty array, which corresponds to the very state of the submitted form's checkboxes (ie: none are checked). The array of values in your formbean for an html:multibox are a list of values of checked checkboxes. So... 1. Form bean looks like this: this.values = { value1, value3, value5 }; 2. Displayed form looks like this: html:multibox property=valuesvalue1/html:multibox 1 html:multibox property=valuesvalue2/html:multibox 2 html:multibox property=valuesvalue3/html:multibox 3 html:multibox property=valuesvalue4/html:multibox 4 html:multibox property=valuesvalue5/html:multibox 5 3. HTML sent to browser looks like this: input type=checkbox name=values value=value1 checked 1 input type=checkbox name=values value=value1 2 input type=checkbox name=values value=value1 checked 3 input type=checkbox name=values value=value1 4 input type=checkbox name=values value=value1 checked 5 4. User unchecks ALL checkboxes, and submits the form. 5. Struts calls reset() on your form - Your reset() method sets this.values = new String[0] 6. Struts populates your form, and _doesn't touch values_, because nothing is checked, so values remains an empty array. Sound good? - Scott - 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]
Re: multibox not works when all checkboxes are unselected!
I dont' have such a sequence like that, but you can get the same when you read the source code of the RequestProcessor class. starki78 wrote: Thanks for this great explanations I already solved this problem and now 'm quite close to understand it! It would be great to have a sequence diagramm to see this flow submit-reset-populate-validate because knowing this flow isn't quite clear to a normal struts-user. THANKS A LOT starki78 wrote: Hi! I've a large problem with html:multibox. I've tree checkboxes. When I choose one or two or three it arrives correct at the next action! Only then all checkboxes are deselected it remembers the state of the checkboxes that was selected before! The state of the form is session in struts-config. Can you help me with this problem?? I really don't have an idea how to solve it! As Adam J. mentioned, it sounds like you're using a session-scoped bean. Try overriding (if you haven't already) the reset() method of your form bean and resetting the property: public void reset( ActionMapping mapping, HttpServletRequest request ) { this.values = new String[0]; } If you're _not_ using a session bean (and are using a request-scoped one instead), you'll _still_ want to do the above. Using this way in both cases, values from the previous request are discarded. If the web browser doesn't send any checkbox values over (because none are checked), then this.values will be an empty array, which corresponds to the very state of the submitted form's checkboxes (ie: none are checked). The array of values in your formbean for an html:multibox are a list of values of checked checkboxes. So... 1. Form bean looks like this: this.values = { value1, value3, value5 }; 2. Displayed form looks like this: html:multibox property=valuesvalue1/html:multibox 1 html:multibox property=valuesvalue2/html:multibox 2 html:multibox property=valuesvalue3/html:multibox 3 html:multibox property=valuesvalue4/html:multibox 4 html:multibox property=valuesvalue5/html:multibox 5 3. HTML sent to browser looks like this: input type=checkbox name=values value=value1 checked 1 input type=checkbox name=values value=value1 2 input type=checkbox name=values value=value1 checked 3 input type=checkbox name=values value=value1 4 input type=checkbox name=values value=value1 checked 5 4. User unchecks ALL checkboxes, and submits the form. 5. Struts calls reset() on your form - Your reset() method sets this.values = new String[0] 6. Struts populates your form, and _doesn't touch values_, because nothing is checked, so values remains an empty array. Sound good? - Scott - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: multibox not works when all checkboxes are unselected!
Browsers are only required to submit values for checkboxes when they are selected. So when a box is not checked, no value is sent, so the state on the server is not changed. When using session scoped objects to store the value of checkboxes your processing needs to be aware of the fact that values for checkbox=off are not sent. -Adam -Original Message- From: starki78 [mailto:[EMAIL PROTECTED] Sent: Thursday, June 08, 2006 11:40 AM To: user Subject: multibox not works when all checkboxes are unselected! Hi! I've a large problem with html:multibox. I've tree checkboxes. When I choose one or two or three it arrives correct at the next action! Only then all checkboxes are deselected it remembers the state of the checkboxes that was selected before! The state of the form is session in struts-config. Can you help me with this problem?? I really don't have an idea how to solve it! Thanks a lot! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Paychex, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: multibox not works when all checkboxes are unselected!
Hi Adam I just tried: public void reset(ActionMapping mapping, HttpServletRequest request) { multiboxvalues = new String[3]; multiboxvalues[0] = ; multiboxvalues[1] = ; multiboxvalues[2] = ; } And now the problem seems to be solved but to be honest I don't have the knowledge to understand it! Thanks for you advice! Browsers are only required to submit values for checkboxes when they are selected. So when a box is not checked, no value is sent, so the state on the server is not changed. When using session scoped objects to store the value of checkboxes your processing needs to be aware of the fact that values for checkbox=off are not sent. -Adam -Original Message- From: starki78 [mailto:[EMAIL PROTECTED] Sent: Thursday, June 08, 2006 11:40 AM To: user Subject: multibox not works when all checkboxes are unselected! Hi! I've a large problem with html:multibox. I've tree checkboxes. When I choose one or two or three it arrives correct at the next action! Only then all checkboxes are deselected it remembers the state of the checkboxes that was selected before! The state of the form is session in struts-config. Can you help me with this problem?? I really don't have an idea how to solve it! Thanks a lot! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Paychex, Inc. - 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]
Re: multibox not works when all checkboxes are unselected!
starki78 wrote: Hi! I've a large problem with html:multibox. I've tree checkboxes. When I choose one or two or three it arrives correct at the next action! Only then all checkboxes are deselected it remembers the state of the checkboxes that was selected before! The state of the form is session in struts-config. Can you help me with this problem?? I really don't have an idea how to solve it! As Adam J. mentioned, it sounds like you're using a session-scoped bean. Try overriding (if you haven't already) the reset() method of your form bean and resetting the property: public void reset( ActionMapping mapping, HttpServletRequest request ) { this.values = new String[0]; } If you're _not_ using a session bean (and are using a request-scoped one instead), you'll _still_ want to do the above. Using this way in both cases, values from the previous request are discarded. If the web browser doesn't send any checkbox values over (because none are checked), then this.values will be an empty array, which corresponds to the very state of the submitted form's checkboxes (ie: none are checked). The array of values in your formbean for an html:multibox are a list of values of checked checkboxes. So... 1. Form bean looks like this: this.values = { value1, value3, value5 }; 2. Displayed form looks like this: html:multibox property=valuesvalue1/html:multibox 1 html:multibox property=valuesvalue2/html:multibox 2 html:multibox property=valuesvalue3/html:multibox 3 html:multibox property=valuesvalue4/html:multibox 4 html:multibox property=valuesvalue5/html:multibox 5 3. HTML sent to browser looks like this: input type=checkbox name=values value=value1 checked 1 input type=checkbox name=values value=value1 2 input type=checkbox name=values value=value1 checked 3 input type=checkbox name=values value=value1 4 input type=checkbox name=values value=value1 checked 5 4. User unchecks ALL checkboxes, and submits the form. 5. Struts calls reset() on your form - Your reset() method sets this.values = new String[0] 6. Struts populates your form, and _doesn't touch values_, because nothing is checked, so values remains an empty array. Sound good? - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multibox error
Is that table inside a html:form? Chris Pat wrote: Hello I am using TC5.5.9,JSTL1.1,Struts1.2 With this code: table width=476 height=110 border=1 tr tdnbsp;/td tdhtml:multibox property=strArray value=Value1//td tdnbsp;/td /tr tr tdnbsp;/td tdnbsp;/td tdnbsp;/td /tr /table I have made sure my actionForm has the s/getter for checkbox1, checkbox2 strArray. Made sure the reset is setting the booleans to false. The page comes up without the html:multibox tag, so everything else is correct. Except for the error below. It seems like a tag library issue. Any and all insight welcomed. tia. I am getting javax.servlet.ServletException: Cannot find bean under name org.apache.struts.taglib.html.BEAN org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) org.apache.jsp.jsp2_jsp._jspService(org.apache.jsp.jsp2_jsp:107) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:195) org.apache.jsp.jsp2_jsp._jspx_meth_html_multibox_0(org.apache.jsp.jsp2_jsp:125) org.apache.jsp.jsp2_jsp._jspService(org.apache.jsp.jsp2_jsp:88) __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multibox error
is your form mapping correct in struts-config??? On 10/29/05, Chris Pat [EMAIL PROTECTED] wrote: Hello I am using TC5.5.9,JSTL1.1,Struts1.2 With this code: table width=476 height=110 border=1 tr td/td tdhtml:multibox property=strArray value=Value1//td td/td /tr tr td/td td/td td/td /tr /table I have made sure my actionForm has the s/getter for checkbox1, checkbox2 strArray. Made sure the reset is setting the booleans to false. The page comes up without the html:multibox tag, so everything else is correct. Except for the error below. It seems like a tag library issue. Any and all insight welcomed. tia. I am getting javax.servlet.ServletException: Cannot find bean under name org.apache.struts.taglib.html.BEAN org.apache.jasper.runtime.PageContextImpl.doHandlePageException( PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePageException( PageContextImpl.java:781) org.apache.jsp.jsp2_jsp._jspService(org.apache.jsp.jsp2_jsp:107) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java :322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:195) org.apache.jsp.jsp2_jsp._jspx_meth_html_multibox_0( org.apache.jsp.jsp2_jsp:125) org.apache.jsp.jsp2_jsp._jspService(org.apache.jsp.jsp2_jsp:88) __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Multibox problem
Code where i put the values back: map.put(districtIds, stringArr); where stringArr is an array of what the user selected. - This is not the same as calling setDistrictIds. You need to call setDistrictIds(stringArr) explicitly.
RE: Multibox problem
Hi- Thanks for the response. The map is in helper class and i dont want my helper class to know anything about struts or actionForm. Thanks, Shyam Apte, Dhanashree (Noblestar) [EMAIL PROTECTED] 07/06/2005 11:45 AM Please respond to Struts Users Mailing List To: 'Struts Users Mailing List' user@struts.apache.org cc: Subject:RE: Multibox problem Code where i put the values back: map.put(districtIds, stringArr); where stringArr is an array of what the user selected. - This is not the same as calling setDistrictIds. You need to call setDistrictIds(stringArr) explicitly.
Re: Multibox
From: Ben Taylor [EMAIL PROTECTED] Can anyone let me know how to automatically check checkboxes? Set the underlying form property and the framework will automatically render checked checkboxes. I have: c:forEach items=${accountMap} var=item html-el:multibox property=accounts value=${item.key}/ c:out value=${item.key}/ c:out value=${item.value.costCenterDesc}/ /c:forEach The form property accounts is a String[] containing account numbers. So this displays all of the accounts in accountMap, and 'checks' the boxes next to the ones that match the values in the accounts form property. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multibox
The multibox is bound to the selectedModule property of your form. Prior to displaying the page, populate selectedModule property of the form with its corresponding row.id values. When html:multibox .../ is invoked on the page, it will recongize the relationship and render the checkboxes as checked. /robert Ben Taylor wrote: Hi, Can anyone let me know how to automatically check checkboxes? Below is my current code: html:multibox property=selectedModules bean:write name=row property=id/ /html:multibox This is one of the many ways I've tried to get it to work: html:multibox property=selectedModules property=${row.id} {some Boolean equation} /html:multibox Cheers for you help! - 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]
Re: Multibox
Cheers, I've manged to get the ticks appearing now... However although they load fine on the first load they do not move after that. i.e. I can change which ones are selected and it'll go off and update the db but when I load the page again the origonal ticks are still shown. I've tried calling setting the String[] to null as well as each value to false but nothing seems to work :o( On Sat, 19 Mar 2005 18:51:30 -0500, Robert Taylor [EMAIL PROTECTED] wrote: The multibox is bound to the selectedModule property of your form. Prior to displaying the page, populate selectedModule property of the form with its corresponding row.id values. When html:multibox .../ is invoked on the page, it will recongize the relationship and render the checkboxes as checked. /robert Ben Taylor wrote: Hi, Can anyone let me know how to automatically check checkboxes? Below is my current code: html:multibox property=selectedModules bean:write name=row property=id/ /html:multibox This is one of the many ways I've tried to get it to work: html:multibox property=selectedModules property=${row.id} {some Boolean equation} /html:multibox Cheers for you help! - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multibox
Ben Taylor wrote: Cheers, I've manged to get the ticks appearing now... However although they load fine on the first load they do not move after that. i.e. I can change which ones are selected and it'll go off and update the db but when I load the page again the origonal ticks are still shown. One reason could be that you defined the accompanying form with scope=session. If so, are you sure you need this? Then again, it could be that a method is pre-populating the checkboxes by retrieving the relevant values from the database that you just inserted. Can you post more code? Vamsee. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Multibox DynaActionForm
You will need to set the selectedCompanies in the ActionForm so that the html:multibox .../ can determine which companies have been selected by comparing the company id against the selected company id. If allCompanies does not change per user, you may want to place that in the ServletContext on application startup to avoid the database hit everytime that action is executed. robert -Original Message- From: Jaakko Rytinki [mailto:[EMAIL PROTECTED] Sent: Thursday, December 09, 2004 9:14 AM To: Struts Users Mailing List Subject: Multibox DynaActionForm How I can prepopulate a form containing a multibox when using DynaActionForms? The following code doesn't seem to work - it wont check any checkboxes (why?) --- Action which prepopulates the form: --- String[] companies = MyDBTools.getUser(userId).getCompanies(); ArrayList allCompanies = MyDBTools.getAllCompanies(); _request.setAttribute(selectedCompanies, companies); _request.setAttribute(allCompanies, allCompanies ); --- Form --- logic:iterate id=company name=allCompanies html:multibox property=selectedCompanies bean:write name=company property=id/ /html:multibox bean:write name=company property=name/ br /logic:iterate --- Form-bean --- form-bean name=forms.myForm type=org.apache.struts.validator.DynaValidatorForm form-property name=selectedCompanies type=java.lang.String[] / /form-bean - 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]
RE: Multibox DynaActionForm
Ah.. stupid me =) So the solution with dynaactionform is: --- public ActionForward execute(ActionMapping _mapping, ActionForm _form, HttpServletRequest _request, HttpServletResponse _response) throws Exception { DynaActionForm dynaForm = (DynaActionForm) _form; String userId = (String) dynaForm.get(userId); String[] companies = MyDBTools.getUser(userId).getCompanies(); ArrayList allCompanies = MyDBTools.getAllCompanies(); dynaForm.set(selectedCompanies, companies); _request.setAttribute(allCompanies, allCompanies ); return _mapping.findForward(continue); } -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED] Sent: 9. joulukuuta 2004 17:13 To: Struts Users Mailing List Subject: RE: Multibox DynaActionForm You will need to set the selectedCompanies in the ActionForm so that the html:multibox .../ can determine which companies have been selected by comparing the company id against the selected company id. If allCompanies does not change per user, you may want to place that in the ServletContext on application startup to avoid the database hit everytime that action is executed. robert -Original Message- From: Jaakko Rytinki [mailto:[EMAIL PROTECTED] Sent: Thursday, December 09, 2004 9:14 AM To: Struts Users Mailing List Subject: Multibox DynaActionForm How I can prepopulate a form containing a multibox when using DynaActionForms? The following code doesn't seem to work - it wont check any checkboxes (why?) --- Action which prepopulates the form: --- String[] companies = MyDBTools.getUser(userId).getCompanies(); ArrayList allCompanies = MyDBTools.getAllCompanies(); _request.setAttribute(selectedCompanies, companies); _request.setAttribute(allCompanies, allCompanies ); --- Form --- logic:iterate id=company name=allCompanies html:multibox property=selectedCompanies bean:write name=company property=id/ /html:multibox bean:write name=company property=name/ br /logic:iterate --- Form-bean --- form-bean name=forms.myForm type=org.apache.struts.validator.DynaValidatorForm form-property name=selectedCompanies type=java.lang.String[] / /form-bean - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Multibox deselection problem
use disabled instead of readonly. IIRC , HTML rarely uses readonly -- its mostly disabled attribute everywhere. It works just fine for me. html:multibox property=selectedCheckboxes disabled=truebean:write name=item//html:multibox -Original Message- From: Olivier Croisier [mailto:[EMAIL PROTECTED] Sent: Monday, November 15, 2004 4:10 AM To: Struts Users Mailing List Subject: Re: Multibox deselection problem Hi ! Thank you for you help, it works fine now ! BTW, it seems like Struts does not support all standart HTML options : I had to use a pure HTML INPUT tag because the readonly attribute does not exist in Struts, and I think this mix is a bit dirty. But it works... (onLoad not supported either...) Olivier Croisier This is a problem with HTTP: when all the checkboxes are deselected, the browser doesn't send anything back, so you get the default of what you started with. To solve this problem you must ensure that at least one box is always selected. I solved this problem by creating an additional checkbox that is hidden, read-only and selected. This will ensure that the browser sends something back. String[] defaultEntities = {A, B, C, D, filler}; tr style=display:none;tdhtml:multibox property=marketing value=filler//td/tr Wiebe -Original Message- From: Olivier Croisier [mailto:[EMAIL PROTECTED] Sent: Friday, November 12, 2004 6:47 AM To: [EMAIL PROTECTED] Subject: Multibox deselection problem Hi ! I have a problem with the Multibox behaviour. I have checked the online doc but nothing helped me so far... Here is my problem : My app workflow is : prepareImportAction.do - Import.jsp - processImportAction.do In the prepareImportAction.do, I initialize the entities var (of type String[], in session scope), so that the checkboxes are checked by default when the jsp page is displayed : String[] defaultEntities = {A, B, C, D}; myform.set(entities, defaultEntities); In the jsp page, I have a set of : html:multibox property=entities value=A/ html:multibox property=entities value=B/ html:multibox property=entities value=C/ html:multibox property=entities value=D/ I also have a small javascript that allows the user to select or deselect all checkboxes in one click : function checkAll(field) { var i; for (i=0;ifield.length;i++) { field[i].checked=true; } } (nearly the same for de-selecting all checkboxes) Now here is my problem. When I de-select all the checkboxes in my jsp page, by hand or by javascript, my processImport.do receives a String[] array containing the entities that were defined in preparaImport.do as default, instead of an empty array. This only happens only when all entities are deselected : if a single one is selected, I get the desired behaviour. May you help me to understand where I am wrong and why it doesn't work please? Olivier Croisier -- CROISIER Olivier Software Engineer Thales IS - ANS [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The information contained in this message is intended only for the recipient, and may be a confidential attorney-client communication or may otherwise be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, please be aware that any dissemination or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by replying to the message and deleting it from your computer. Thank you, Standard Poor's - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multibox deselection problem
Hi ! Thank you for you help, it works fine now ! BTW, it seems like Struts does not support all standart HTML options : I had to use a pure HTML INPUT tag because the readonly attribute does not exist in Struts, and I think this mix is a bit dirty. But it works... (onLoad not supported either...) Olivier Croisier This is a problem with HTTP: when all the checkboxes are deselected, the browser doesn't send anything back, so you get the default of what you started with. To solve this problem you must ensure that at least one box is always selected. I solved this problem by creating an additional checkbox that is hidden, read-only and selected. This will ensure that the browser sends something back. String[] defaultEntities = {A, B, C, D, filler}; tr style=display:none;tdhtml:multibox property=marketing value=filler//td/tr Wiebe -Original Message- From: Olivier Croisier [mailto:[EMAIL PROTECTED] Sent: Friday, November 12, 2004 6:47 AM To: [EMAIL PROTECTED] Subject: Multibox deselection problem Hi ! I have a problem with the Multibox behaviour. I have checked the online doc but nothing helped me so far... Here is my problem : My app workflow is : prepareImportAction.do - Import.jsp - processImportAction.do In the prepareImportAction.do, I initialize the entities var (of type String[], in session scope), so that the checkboxes are checked by default when the jsp page is displayed : String[] defaultEntities = {A, B, C, D}; myform.set(entities, defaultEntities); In the jsp page, I have a set of : html:multibox property=entities value=A/ html:multibox property=entities value=B/ html:multibox property=entities value=C/ html:multibox property=entities value=D/ I also have a small javascript that allows the user to select or deselect all checkboxes in one click : function checkAll(field) { var i; for (i=0;ifield.length;i++) { field[i].checked=true; } } (nearly the same for de-selecting all checkboxes) Now here is my problem. When I de-select all the checkboxes in my jsp page, by hand or by javascript, my processImport.do receives a String[] array containing the entities that were defined in preparaImport.do as default, instead of an empty array. This only happens only when all entities are deselected : if a single one is selected, I get the desired behaviour. May you help me to understand where I am wrong and why it doesn't work please? Olivier Croisier -- CROISIER Olivier Software Engineer Thales IS - ANS [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multibox deselection problem
Olivier Croisier wrote the following on 11/12/2004 9:46 AM: Now here is my problem. When I de-select all the checkboxes in my jsp page, by hand or by javascript, my processImport.do receives a String[] array containing the entities that were defined in preparaImport.do as default, instead of an empty array. Use the form reset method to always set the String array to an empty array first. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Multibox deselection problem
This is a problem with HTTP: when all the checkboxes are deselected, the browser doesn't send anything back, so you get the default of what you started with. To solve this problem you must ensure that at least one box is always selected. I solved this problem by creating an additional checkbox that is hidden, read-only and selected. This will ensure that the browser sends something back. String[] defaultEntities = {A, B, C, D, filler}; tr style=display:none;tdhtml:multibox property=marketing value=filler//td/tr Wiebe -Original Message- From: Olivier Croisier [mailto:[EMAIL PROTECTED] Sent: Friday, November 12, 2004 6:47 AM To: [EMAIL PROTECTED] Subject: Multibox deselection problem Hi ! I have a problem with the Multibox behaviour. I have checked the online doc but nothing helped me so far... Here is my problem : My app workflow is : prepareImportAction.do - Import.jsp - processImportAction.do In the prepareImportAction.do, I initialize the entities var (of type String[], in session scope), so that the checkboxes are checked by default when the jsp page is displayed : String[] defaultEntities = {A, B, C, D}; myform.set(entities, defaultEntities); In the jsp page, I have a set of : html:multibox property=entities value=A/ html:multibox property=entities value=B/ html:multibox property=entities value=C/ html:multibox property=entities value=D/ I also have a small javascript that allows the user to select or deselect all checkboxes in one click : function checkAll(field) { var i; for (i=0;ifield.length;i++) { field[i].checked=true; } } (nearly the same for de-selecting all checkboxes) Now here is my problem. When I de-select all the checkboxes in my jsp page, by hand or by javascript, my processImport.do receives a String[] array containing the entities that were defined in preparaImport.do as default, instead of an empty array. This only happens only when all entities are deselected : if a single one is selected, I get the desired behaviour. May you help me to understand where I am wrong and why it doesn't work please? Olivier Croisier -- CROISIER Olivier Software Engineer Thales IS - ANS [EMAIL PROTECTED] - 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]
Re: Multibox/LabelValueBean Input Forms -- Paged Input
The logic iterate tag has offset and length attributes which you can use to control display subsets to a collection/array. So if you wanted to show the second page of 10 logic:iterate id=myLabelBeans name=myForm property=myLabelBeans offset=10 length=10 html:checkbox name=myLabelBeans property=myValue indexed=true bean:write name=myLabelBeans property=myLabel/ /html:checkbox /logic:iterate If you are using jstl then then c:forEach tag has begin and end attributes c:forEach var=myLabelBeans items=$(myForm.myLabelBeans} begin=10 end=19 html:checkbox name=myLabelBeans property=myValue indexed=true bean:write name=myLabelBeans property=myLabel/ /html:checkbox /c:forEach Niall - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 11, 2004 1:47 AM Subject: Multibox/LabelValueBean Input Forms -- Paged Input I have found an example on the net where a LabelValueBean array and a string array are encapsulated inside a custom ActionForm object giving the user the ability to select checkboxed values and store the values behind the scene with labeling each checkbox with the LabelValueBean's label property. This works great for small amounts of checkbox input, such as less than 10; however the goal I have been tasked with is to expand on this where the data set is say 100 elements and each form page displays a subset of 10 items of the entire 100 element data set. Once the user has traversed through all 100 items or selected those they wish, the form should contain an array of items that range the entire 100 element dataset which the user has selected. Any thoughts, suggestions, or examples of something like this others have done in the past? Chris - 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]
Re: multibox mayhem
i had to add logic:empty tags around the bean:write name=bean2/ because there were some trailing 'null' values in the Integer[] after reading from DB. pls [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have one multibox per page on a few pages. Each page name is represented by the 'key' property of a HashMap. Each selected checkbox number is stored in Integer[]'s in the 'value' property of a HashMap. After selecting all of the checks, the user is forwarded to a confirmation.jsp which displays the selections. the code: (i removed table formatting for clarity) logic:iterate id=bean1 name=multiBoxForm property=allofem bean:write name=bean1 property=key/ logic:iterate id=bean2 name=bean1 property=value bean:write name=bean2 / /logic:iterate /logic:iterate this works fine to display the selections when they are read from the original ActionForm. i can update the db and then read them back which works fine too. i have confirmed that i have a HashMap with the correct Integer[]'s from the db inside, however the same code as the previous is located in profile.jsp and it returns the following JasperException: Cannot find bean bean2 in any scope Any ideas? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multibox mayhem
from this code : bean:write name=bean1 property=key/ I guess that bean1 must be an object inside 'allofem' So why are you trying to iterate an object : logic:iterate id=bean2 name=bean1 property=value pls wrote: i had to add logic:empty tags around the bean:write name=bean2/ because there were some trailing 'null' values in the Integer[] after reading from DB. pls [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have one multibox per page on a few pages. Each page name is represented by the 'key' property of a HashMap. Each selected checkbox number is stored in Integer[]'s in the 'value' property of a HashMap. After selecting all of the checks, the user is forwarded to a confirmation.jsp which displays the selections. the code: (i removed table formatting for clarity) logic:iterate id=bean1 name=multiBoxForm property=allofem bean:write name=bean1 property=key/ logic:iterate id=bean2 name=bean1 property=value bean:write name=bean2 / /logic:iterate /logic:iterate this works fine to display the selections when they are read from the original ActionForm. i can update the db and then read them back which works fine too. i have confirmed that i have a HashMap with the correct Integer[]'s from the db inside, however the same code as the previous is located in profile.jsp and it returns the following JasperException: Cannot find bean bean2 in any scope Any ideas? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]