struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: <html:multibox> is not sending the checked checkboxes value
Date Mon, 03 Apr 2006 00:54:00 GMT
You set the checkbox's value using the 'value' attribute, funilly enough 
:-)

L.

王曾wang_zeng wrote:
> hi:
>    i have a question. in a multibox,the property attribute should be pointed
> to an array in the form bean,and this array will be checked to see if
> there exists such a element who's value equals to the value set in the
> multibox. my question is how to set the value of multibox which will be used
> to find a match with in the array especially when the multibox's value dose
> not equal to the label displayed on the check box in IE.
> 
> 
> 2006/4/1, Max Cooper <max@maxcooper.com>:
>> 2 things come to mind:
>>
>> 1) Make sure your ActionForm has the appropriate setter method. It wont
>> be setDenyCodes(String value) since there can be many values. IIRC, you
>> need a setter that takes a String array as an argument. I could be wrong
>> -- do some research to be sure.
>>
>> 2) Make sure the URL of the submit (when using GET) doesn't get so long
>> that IE chops the end off. Check all the boxes (so the URL will be at
>> its longest) to test. I think this happens around 4000 characters or so.
>> Using a POST avoids this limitation in a reliable manner.
>>
>> -Max
>>
>> Tarun Reddy wrote:
>>> Hi Vijay,
>>> It's working fine now. I've just added a method="GET" attribute to
>>> <html:form> tag. It's working perfectly fine. I don't have any idea how
>> this
>>> solved the problem. Thanks for all your time.
>>>
>>> Thanks,
>>> Tarun.
>>>
>>> On 3/31/06, Tarun Reddy <btarunreddy@gmail.com> wrote:
>>>
>>>> Thanks Vijay! I've verified the value returned by
>>>> request.getParameterValues("denyCodes") even before sending out this
>> mail.
>>>> I don't have any clue on how to proceed further. I'll try debugging it
>> more.
>>>> Thanks,
>>>> Tarun.
>>>>
>>>>
>>>> On 3/31/06, vijay venkataraman <vijayv@ltp.soft.net> wrote:
>>>>
>>>>> Tarun,
>>>>> If the value in being rendered is in string array pointed by the
>>>>> property it will be rendered with checked attribute set. I know it
>>>>> works.
>>>>> It is bit weired that the set method is not being called i am not able
>>>>> to find what is happening. Do you see the values coming fine in the
>>>>> HttpRequest?
>>>>> If you debug and view your HttpRequest - If you have *selected* some
>>>>> checkboxes then you should see a parameter by name denyCodes and to
>> that
>>>>> there will be a array containing the selected values in the array.
>> Sorry
>>>>> i am stuck with something deep and cannot probe any further now.
>> Pulling
>>>>> the bean util source code along with Struts source code and seeing what
>>>>> happens will give you a clear idea.
>>>>>
>>>>> Vijay Venkataraman
>>>>>
>>>>> Tarun Reddy wrote:
>>>>>
>>>>>
>>>>>> Hi Vijay,
>>>>>> Thanks for the reply! I had a look at the HTML source generated by
JSP
>>>>> page
>>>>>
>>>>>> which contains multibox tag. Here are some sample entries,
>>>>>>
>>>>>> <form name="denyForm" method="post" action="/testingtool/deny.do">
>>>>>>   <table>
>>>>>>       <tr align="center">    <input type="submit"
>>>>> value="Submit"></tr>
>>>>>
>>>>>>           <tr> <input type="checkbox" name="denyCodes"
>>>>>> value="216">216</tr>
>>>>>>          <tr>  <input type="checkbox" name="denyCodes"
>>>>>> value="415">415</tr>
>>>>>>           <tr> <input type="checkbox" name="denyCodes"
>>>>> value="05">05</tr>
>>>>>
>>>>>> Let me tell you, <bean:write> tag nested in the <html:multibox>
tag
>>>>> takes
>>>>>
>>>>>> care of setting this value attirbute to the same as label. The HTML
>>>>> source
>>>>>
>>>>>> also proved that this problem is not related to setting value
>>>>> attribute.
>>>>>
>>>>>> Second point is, yeah there's a slight confusion in the use of
>> multibox
>>>>> tag.
>>>>>
>>>>>> In the specs they say that you can make ur checkboxes checked based
on
>>>>> the
>>>>>
>>>>>> values present in, string array in the ActionForm. But can you tell
me
>>>>>> whether we can make selections among multiple checkboxes and then
send
>>>>> the
>>>>>
>>>>>> values of the checked checkboxes to the Action class? I'm surprised
to
>>>>> see
>>>>>
>>>>>> that the setter method was never called while submitting the form
to
>>>>> the
>>>>>
>>>>>> action class. Please suggest me.
>>>>>>
>>>>>>
>>>>>> On 3/31/06, vijay venkataraman <vijayv@ltp.soft.net> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> The struts doc goes like this :
>>>>>>>
>>>>>>> *Multibox:*
>>>>>>> **
>>>>>>>
>>>>>>> Renders an HTML <input> element of type |checkbox|, whose
"checked"
>>>>>>> status is initialized based on whether the specified value matches
>> one
>>>>>>> of the elements of the underlying property's array of current
values.
>>>>>>> This element is useful when you have large numbers of checkboxes,
and
>>>>>>> prefer to combine the values into a single array-valued property
>>>>> instead
>>>>>
>>>>>>> of multiple boolean properties. This tag is only valid when nested
>>>>>>> inside a form tag body.
>>>>>>>
>>>>>>> *WARNING*: In order to correctly recognize cases where none of
the
>>>>>>> associated checkboxes are selected, the |ActionForm| bean associated
>>>>>>> with this form must include a statement setting the corresponding
>>>>> *array
>>>>>
>>>>>>> to zero length in the |reset()| method.
>>>>>>> *
>>>>>>>
>>>>>>> See the rendered html and make sure that check boxes are rendered
>> with
>>>>>>> the correct name.
>>>>>>> I don't see you setting any value to the value attribute of multibox.
>>>>>>> It is the value you set that is posted back.
>>>>>>>
>>>>>>> I don't know much about bean and iteration tag.
>>>>>>>
>>>>>>> Regards,
>>>>>>> Vijay Venkataraman
>>>>>>>
>>>>>>>
>>>>>>> Tarun Reddy wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi All,
>>>>>>>> I've been wasting my time on one issue pertaining to <html:multibox>
>>>>> tag.
>>>>>
>>>>>>>> I'm writing a code which should generate multiple checkboxes
>>>>> dynamically
>>>>>
>>>>>>> on
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> a JSP page. The JSP should send the checked checkboxes value
to the
>>>>>>>>
>>>>>>>>
>>>>>>> Action
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> class. But it's not sending any values. I've tried many approaches
>>>>> like
>>>>>
>>>>>>>> 1)initialized all the elements in the String[] to "" in the
reset()
>>>>>>>>
>>>>>>>>
>>>>>>> method
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> 2)tried retrieving the checked values using String[] codes=
>>>>>>>> request.getParameterValues("denyCodes");
>>>>>>>> None of the above methods worked for me. I'm using Weblogic
8.1 and
>>>>>>>>
>>>>>>>>
>>>>>>> Struts
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> 1.2.8. I've tried with Struts 1.1 too. Here's my code.
>>>>>>>> -------------------
>>>>>>>> public class DenyForm extends ActionForm {
>>>>>>>>  private String[] denyCodes= new String[80];
>>>>>>>>  public String[] getDenyCodes(){
>>>>>>>>      return denyCodes;
>>>>>>>>  }
>>>>>>>>  public void setDenyCodes(String[] denycodes){
>>>>>>>>      this.denyCodes = denycodes;
>>>>>>>>  }
>>>>>>>>  public void reset(ActionMapping mapping, HttpServletRequest
>>>>> request)
>>>>>
>>>>>>> {
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>      for(int i=0;i<80;i++){
>>>>>>>>          denyCodes[i] = "";
>>>>>>>>      }
>>>>>>>>  }
>>>>>>>> }
>>>>>>>> ------------------------denycodes.jsp page is like this,
>>>>>>>> <html:form action="deny">
>>>>>>>>  <table>
>>>>>>>>      <tr align="center">    <html:submit /></tr>
>>>>>>>>      <logic:iterate name="denialCodes" id="code">
>>>>>>>>          <tr>
>>>>>>>>              <html:multibox  property="denyCodes" >
>>>>>>>>                  <bean:write name="code" />
>>>>>>>>              </html:multibox><bean:write name="code"/>
>>>>>>>>          </tr>
>>>>>>>>      </logic:iterate>
>>>>>>>>  </table><br>
>>>>>>>> </html:form>
>>>>>>>> ---------------------------------------Action Class is
>>>>>>>> public class DenyAction extends Action {
>>>>>>>>  public ActionForward execute(ActionMapping mapping, ActionForm
>>>>> form,
>>>>>
>>>>>>>>          HttpServletRequest request, HttpServletResponse
response)
>>>>>>>>
>>>>>>>>
>>>>>>> throws
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Exception{
>>>>>>>>
>>>>>>>>      HttpSession session = request.getSession();
>>>>>>>>      DenyForm denyForm = (DenyForm)form;
>>>>>>>>      String[] codes = denyForm.getDenyCodes();
>>>>>>>> //            String[] codes = request.getParameterValues
>>>>> ("denyCodes");
>>>>>
>>>>>>>>       log.debug("codes array length is:"+codes.length);
>>>>>>>>      session.setAttribute("denyCodes",codes);
>>>>>>>>      return mapping.findForward("success");
>>>>>>>>  }
>>>>>>>> }
>>>>>>>> --------------------------------------------------
>> struts-config.xmlentry
>>>>>>>>
>>>>>>> is
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> like this
>>>>>>>>
>>>>>>>>   <form-bean name="denyForm" type="tars.form.DenyForm
" />
>>>>>>>>
>>>>>>>>      <action path="/deny" type="tars.action.DenyAction"
>>>>>>>>
>>>>>>>>
>>>>>>> name="denyForm">
>>>>>>>
>>>>>>>
>>>>>>>>          <forward name="success" path="/query.jsp" />
>>>>>>>>      </action>
>>>>>>>> ------------------------------------------------------------------
>>>>>>>>
>>>>>>>> codes.length is always returning 0 as the length. I've added
some
>>>>> debug
>>>>>
>>>>>>>> statements in the ActionForm's set method to see whether
it's being
>>>>>>>>
>>>>>>>>
>>>>>>> called
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> or not. To my surprise it was never called. That's what baffling
me.
>>>>> This
>>>>>
>>>>>>> is
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> really urgent. I would really appreciate if someone  could
help me
>>>>> out.
>>>>>
>>>>>>>> Thanks,
>>>>>>>> Tarun.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ------------------------------DISCLAIMER------------------------------
>>>>>>> This message is for the named person's use only. It may contain
>>>>>>> confidential, proprietary or legally privileged information.
No
>>>>>>> confidentiality or privilege is waived or lost by any
>> mistransmission.
>>>>>>> If you receive this message in error, please immediately delete
it
>> and
>>>>>>> all copies of it from your system, destroy any hard copies of
it and
>>>>>>> notify the sender. You must not, directly or indirectly, use,
>>>>> disclose,
>>>>>
>>>>>>> distribute, print, or copy any part of this message if you are
not
>> the
>>>>>>> intended recipient.
>>>>>>>
>>>>>>> Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries
each
>>>>>>> reserve the right to monitor all e-mail communications through
its
>>>>>>> networks.
>>>>>>>
>>>>>>> Any views expressed in this message are those of the
>>>>>>> individual sender, except where the message states otherwise
and the
>>>>>>> sender is authorized to state them to be the views of any such
>> entity.
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>> ------------------------------DISCLAIMER------------------------------
>>>>> This message is for the named person's use only. It may contain
>>>>> confidential, proprietary or legally privileged information. No
>>>>> confidentiality or privilege is waived or lost by any mistransmission.
>>>>>
>>>>> If you receive this message in error, please immediately delete it and
>>>>> all copies of it from your system, destroy any hard copies of it and
>>>>> notify the sender. You must not, directly or indirectly, use, disclose,
>>>>> distribute, print, or copy any part of this message if you are not the
>>>>> intended recipient.
>>>>>
>>>>> Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each
>>>>> reserve the right to monitor all e-mail communications through its
>>>>> networks.
>>>>>
>>>>> Any views expressed in this message are those of the
>>>>> individual sender, except where the message states otherwise and the
>>>>> sender is authorized to state them to be the views of any such entity.
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message