Html:checkbox

I have a checkbox in my JSP which is checkd a the beginning.
My getters and setters inside the ActionForm is lik
private String chkFlag;
public void reset(ActionMapping mapping, HttpServletRequest request) {
          ChkFlg = false;
public boolean isChkFlg() {
          return ChkFlg;
     public void setChkFlg(boolean ChkFlg) {
                            this.ChkFlg = ChkFlg
     }In my logic i have
//actionForm is the name of the ActionForm
if(actionForm.isChkFlg() == true){
//do sth here
}else{
//do sth here
}However, no matter whether the checkbox is selected or not it always gives me false
What am i doing wrong? how can i use checkbox?

Please post Struts questions on a Struts forum or in the JSP forum [ http://forum.java.sun.com/forum.jspa?forumID=45 ]

Similar Messages

  • Is There a Bug in pdk-html:checkbox  .... ?

    I am attempting to use the <pdk-html:checkbox ....> tag and cannot get it to work.
    When the user presses the Submit button and my code processes the checkbox the checkbox does not reflect that the user checked it.
    The code I wrote in the .jsp is:
    <pdk-html:checkbox value="yes" name="facListBean" property="check_box"></pdk-html:checkbox>
    When the page gets rendered the code gets translated to :
    <input type="checkbox" name="check_box" value="yes">
    Notice the name is not qualified in any way. In the other pdk-html tags I have used the name gets prepended with qualifying data.
    Is this a bug in the pdk-html:checkbox tag? Has anyone else use the pdk-html:checkbox successfully?

    Thanks Don,
    I was unaware of the multibox tag so I looked into it after reading your response. I tried to implement the following example code I found on the Husted web site:
    JSP:
    <logic:iterate id="item" property="items">
    <html:multibox value="val" property="selectedItems">
    <bean:write name="item"/>
    </html:multibox>
    <bean:write name="item"/>
    </logic:iterate>
    Action Form
    private String[] selectedItems = {};
    private String[] items = {"UPS","FedEx","Airborne"};
    public String[] getSelectedItems() {
    return this.selectedItems;
    public void setSelectedItems(String[] selectedItems) {
    this.selectedItems = selectedItems;
    I get the error:
    "You must specify the value attribute or nested tag content"
    I added a value attribute to the multibox tag but that didn't change the error. Any idea what what I need to do here? What am I missing?
    Thanks,

  • Doubt  in using html:checkbox in struts

    Hi all,
    In my jsp page i have 2 checkboxes name mandatory and active.
    <html:checkbox property="mandatory" value="true"/>
    <html:checkbox property="active" value="true"/>
    Insertion of data works fine,and now my doubt is about the edit mode.
    In edit mode,depending on th value of thethese fields wheteher 0 or 1,checkbox should be checked.how can it be done?
    In th corresponding for,the properties I declared as boolean values.Also reset method is provided .
    Anyone pls help.
    thanks

    It's rather nasty, but you could wrap all your strings in <html></html>. Even so you still have to use entities, but the
    following displays what you want:JLabel lbl = new JLabel("<html>&lt;html>&lt;/html></html>");

  • Html:checkbox - which box is selected and on in what tr

    I have a jsp in which I iterate over a LinkedList of people. Each person gets there own row in a table on the jsp page. In each row is the name of a person in the first <td> and then a checkbox in each of the next three <td>'s.
    A user may order one of three reports on any or each of the names coming from my LinkedList by clicking on a checkbox.
    Right now I am able to determine which report to order by which checkbox is selected in a row, but am unable to determine which row/person to order the report for.
    I've seached this forum and went through the first couple pages of results with no luck. And spent a bit of time on google but can't seem to get the exact keywords to retrieve the results I need.
    Here is a small sample of how I am setting up the table. Just a snippet, names have been changed, you won't be able to compile this.
    <logic:iterate id="person" name="someLogical" property="personsList" type="someDataObjectType">
         <tr>
              <td valign="top" nowrap>
                   <bean:write name="person" property="name"/> �
              </td>
              <td align="center" valign="top">
                   //someForm is my actionForm, and orderReportOne is a boolean being set in the form
                   <html:checkbox name="someForm" property="orderReportOne"/>
              </td>
              <td align="center" valign="top">
                   <html:checkbox name="someForm" property="orderReportTwo"/>
              </td>
              <td align="center" valign="top">
                   <html:checkbox name="someForm" property="orderReportThree"/>
              </td>
         </tr>
    </logic:iterate>The booleans in my form are being set correctly but don't relate to a specific person. They would just order reportOne for each person in the list.
    Edit: I will be leaving soon for the rest of the day and may or may not be able to reply again until monday, but appreciate any responses. Thanks
    Message was edited by:
    Hentay

    It depends on how you're utilising your XML, but ComboBox has selectedIndex property so that you can trace the index number of the item selected.

  • Read/set HTML checkbox in JSP

    Hello,
    I need to directly read and set the state of an HTML checkbox from a JSP page that contains it. It is not sufficient to submit the form and then get the value from the next page; I need to be able to set the value when the page loads, and then on cue, store the (possibly changed) state of the checkbox within the same page.
    How can this be done? Thanks in advance.

    you write the checkbox tag dynamically...
    <input type="checkbox" ... <%= checked ? "checked" : "" %>>
    or use a tag library that does it for you.
    But you can't do it within the page without Javascript. Once it loads in the browser, the Java part of the page is done and gone. So either you use Javascript to alter things in the browser before submitting the form, or you submit the page and recreate it based on what's submitted so far.

  • html:checkbox disabling based on a condition

    does anyone know how to disable the <html:checkbox ?? it should be disabled based on some condition
    thanks

    It is very unclear what you want. There is a disabled flag available to html:checkbox. You could do something like:
    <html:checkbox disabled="<%= somebooleanVar %>" ...and so on. What are you trying to do?
    Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.
    Sure they're new - come get them started!

  • Make html:checkbox selected by default depending upon bean value --struts

    Hi all,
    I have a doubt regarding the html:checkbox .
    I have the following code in my jsp.
    I am giving it inside logic:iterate tag and fetching the value from session scope.
    <html:checkbox property ="readchk" value ="read" indexed="true" onclick="return assignme(this.value,this.checked,'s')"/>
    How to make this checkbox selected by default.
    "readchk" (bean) is in my ActionForm, it has been been assigned either
    0 or 1 .
    I want to make the checkbox selected by default if the readchk is 1
    and the checkbox not selected if the readchk value is 0.
    Could anybody please help me out in fixing this problem.
    Thanks
    Parvathi

    If u give the value for ur check box in the action form it wld be checked!!
    regards
    Shanu

  • HTML Checkbox can raise a OnInputProcessing event???

    Hello all,
    i have a little problem with an application with flow logic page. I have to incorporate a group of html checkbox that raise an event in the OnInputProcessing like an button do. this can be done?? and how can be do it??? . Please help. Thanx in advance

    Hi Mariana,
    If you want to call the OnInputProcessing Event then you need to use htmlb checkbox.
    Here is the sample code....
    In Page with flow logic....
    In Layout section...
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title="Tab Strip" >
        <htmlb:form>
          <htmlb:checkboxGroup id="chkboxgrp" >
            <htmlb:checkbox id      = "cb1"
                            text    = "Red"
                            onClick = "myEvent1" />
            <htmlb:checkbox id      = "cb2"
                            text    = "Green"
                            onClick = "myEvent2" />
            <htmlb:checkbox id      = "cb3"
                            text    = "Blue"
                            onClick = "myEvent3" />
          </htmlb:checkboxGroup>
           <br>
          <%= red %>
          <br>
          <%= green %>
          <br>
          <%= blue %>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    In Page Attributes Section...
    blue     TYPE     STRING
    green     TYPE     STRING
    red     TYPE     STRING
    In OnInputProcessing section...
    data: chkbox1 type ref to cl_htmlb_checkbox,
          chkbox2 type ref to cl_htmlb_checkbox,
          chkbox3 type ref to cl_htmlb_checkbox.
    chkbox1 ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'checkbox'
    id = 'cb1' ).
    chkbox2 ?= CL_HTMLB_MANAGER=>GET_DATA(
    request =  runtime->server->request
    name = 'checkbox'
    id = 'cb2' ).
    chkbox3 ?= CL_HTMLB_MANAGER=>GET_DATA(
    request =  runtime->server->request
    name = 'checkbox'
    id = 'cb3' ).
    DATA: event TYPE REF TO CL_HTMLB_EVENT.
    event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    IF event->name = 'checkbox' AND event->event_type = 'click'.
      case event->id.
        when 'cb1'.
          red = chkbox1->checked.
          if red eq ' '.
            red = 'Not Selected'.
          else.
            red = 'Red Selected'.
          endif.
        when 'cb2'.
          chkbox2 ?= CL_HTMLB_MANAGER=>GET_DATA(
          request =  runtime->server->request
          name = 'checkbox'
          id = 'cb2' ).
          green = chkbox2->checked.
          if green eq ' '.
            green = 'Not Selected'.
          else.
            green = 'Green Selected'.
          endif.
        when 'cb3'.
          chkbox3 ?= CL_HTMLB_MANAGER=>GET_DATA(
          request =  runtime->server->request
          name = 'checkbox'
          id = 'cb3' ).
          blue = chkbox3->checked.
          if blue eq ' '.
            blue = 'Not Selected'.
          else.
            blue = 'Blue Selected'.
          endif.
      endcase.
    ENDIF.
    Hope it solves your problem.
    Regards,
    Maheswaran.B

  • html:checkbox driving me crazy

    Hey frnds
    Can u plz provide me some code for managing a group of checkboxes in struts.
    I m using DynActionForms

    i m having a dyna form like this........\
    <form-bean name="addQuestionForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="answertext" type="java.lang.String[]" />
    <form-property name="correct" type="java.lang.String[]" />
    </form-bean>
    and in my jsp i m using
    <html:multibox property="correct">
    <html:textarea property="answertext" cols="40"></html:textarea>
    </html:multibox>
    but wht i want is tht answertext[] shoulds be dipalyed along with the
    selected checkbox .
    So for this i m using this code in view.jsp
    <logic:iterate name="addQuestionForm" property="answertext" id="answertextt">
    <tr>
    <td width="80%" ></td>
    <html:textarea property="answertext" value="<%=answertextt.toString()%>" cols="40" rows="2" size="40" />
    </td>
    <td width="10%" >
    <html:multibox property="correct" >
    <bean:write name="answertextt" />
    </html:multibox>
    </td>
    </tr>
    </logic:iterate>
    Now in my view.jsp , i m getting all the options and checkboxes , but no option is checked marked.
    Can anyone why is this so ?
    Plz help....

  • Problem using pdk-html:multibox and pdk-html:checkbox

    Hi all,
    I am developing a PDK struts application using OC4J 10.1.2. I have to create some form pages which are going to have some checkboxes. I have tried to follow the following code in order to use the pdk version of the checkbox in my form:
    in jsp file
    <logic:iterate id="item" property="items">
    <pdk-html:multibox property="selectedItems">
    <bean:write name="item"/>
    </pdk-html:multibox>
    <bean:write name="item"/>
    </logic:iterate>
    Given an ActionForm setup like this
    private String[] selectedItems = {};
    private String[] items = {"UPS","FedEx","Airborne"};
    public String[] getSelectedItems() {
    return this.selectedItems;
    public void setSelectedItems(String[] selectedItems) {
    this.selectedItems = selectedItems;
    ....... //getters and setters of items//
    In the reset method I also reinitialize the selectedItems array like :
    selectedItems=new String[]{};
    But the value of the multibox is not reflected in the action class. To my surprise, the html code generated by the server is similar to ordinary checkbox which ideally should carry some portlet specific information like pdk-html:text
    Same is the case with single checkbox. I have created a boolean variable for the single checkbox in the actionForm class. But same problem frustrates me again. The value is not passed simply.
    Can anybody comment. Is this some kind of a bug or may be there is no support for checkbox and multibox in pdkstruts.jar (10.1.2.0.2).
    Best regards,
    Omer

    following below the code that generate the XML. I still need help.
    I hope someone can help me in this issue
    The servlet that generate the XML.
    response.setContentType("text/xml");
    String Xml = "";
    Xml = Xml + "<?xml version=\"1.0\"?>";
    Xml = Xml + "<?xml-stylesheet href=\"/XslGravaCrit.xsl\" type=\"text/xsl\"?>";
    Xml = Xml + "<!-- Here is a sample XML file -->";
    Xml = Xml + "<page>";
    Xml = Xml + "<title>Test Page</title>";
    Xml = Xml + "<content>";
    Xml = Xml + "<paragraph>What you see is what you get!</paragraph>";
    Xml = Xml + "</content>";
    Xml = Xml + "</page>";
    try{
    TransformerFactory tFactory = TransformerFactory.newInstance();
    byte[] arr=Xml.getBytes();
    ByteArrayInputStream bytes=new ByteArrayInputStream(arr);
    Source xsl=new StreamSource("../XslGravaCrit.xsl");
    Templates template=tFactory.newTemplates(xsl);
    Transformer transformer = template.newTransformer();
    transformer.transform(new StreamSource(bytes), new StreamResult(response.getWriter()));
    }catch(Exception e){
    System.out.println("Excecao 100: " + e.getMessage() + e.getLocalizedMessage());
    The XSL XslGravaCrit.xsl
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java"
    version="1.0">
    <xsl:strip-space elements="*"/>
    <xsl:output method="html" indent="yes" version="4.0"/>
    <xsl:template match="page">
    <html>
    <body><b>
    <xsl:value-of select="java:java.util.Date.new()"/>
         </b>
    <xsl:for-each select="/page">
    <xsl:sort select="paragraph"/>
    <xsl:value-of select="paragraph"/>
    </xsl:for-each>
    <i>Hello World</i>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

  • Html Checkbox...is there anyone to help me...

    i am new to html..
    i wowuld like to kno how i can select all checkboxes and deselect all the checkboxes at one click ..
    i mean iwould like to kno how the delete all option in yahoo mail page works....
    i dont want to run javascripts like thing.
    please give me the syntax....

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title></title>
    <script language="JavaScript">
    function selAll()
         var i;
         var len=document.frm.chkbox.length;
         for(i=0; i<len; i++)
              document.frm.chkbox.checked=true;
    </script>
    </head>
    <body>
    <form name=frm>
    Select All <input type="Checkbox" name="selall" onclick="selAll()"><br>
    A <input type="Checkbox" name="chkbox"><br>
    B <input type="Checkbox" name="chkbox"><br>
    C <input type="Checkbox" name="chkbox"><br>
    D <input type="Checkbox" name="chkbox">
    </form>
    </body>
    </html>

  • Html:checkbox tag problem

    I need to use multiple checkbox(i.e One checkbox in each rows).I am using Struts1 and need to capture the list of values which the users selects the checkboxes.Need information to capture the selected values in action class.sample code could be more helpful..

    In Struts i think there are some variables in formbean which will store the value of forms parameters so you can access these values by form object passed in action class.

  • How to get the checked attribute of a checkbox item from a PL/SQL process?

    Hello,
    I have a simple static form with one checkbox linked to a LOV containing one single value. I use this checkbox just to enable/disable other fields via Javascript. I am interested to fetch the "checked" attribute of this checkbox (and not the value of the checkbox) from an After Submit PL/Sql page process, so that I can process only the enabled fields.
    I can already imagine a workaround where we may store via Javascript the checked attribute of this checkbox in an hidden page item and then getting it from there, but I would really like to avoid it, as it would add unnecessary complexity and I would have to add more code to keep the hidden item always in synch with the checkbox status.
    Is there something like the V('page_item') PL/Sql function that can get a different attribute from a page item (like the checked one from a checkbox) and not only its value?
    I searched the forum for an answer to my question, but I couldn't find anything related.
    Thanks a lot,
    Paolo

    Paolo,
    HTML checkboxes are POSTed only if they are checked. So if your "checked" value is 'Y', for example, then your after-submit process can check if the item's value is 'Y' or not. Of course, you must be careful to set that item to null (or some non-checked value) in session state during page rendering so that previous values are not retained.
    Scott

  • Checkbox derived column in report

    I added an HTML checkbox that has the same name for every row and a value of the pk for that row to a report. I also added a submit button.
    The submit button branches back to the same page.
    If I don't check ANY checkbox buttons the submit button just takes me back to the same report. If I even click one checkbox, I get a 404 "Page cannot be found" with the url saying: pls/htmldb/wwv_flow.accept
    why is this procedure doing this? How can I add a derived column containing a checkbox to a report for selection of report rows for further processing or adding of these rows to a "shopping cart/basket".

    Enough with this ..... link
    http://www.oracle.com/technology/products/database/htmldb/howtos/checkbox.html
    How many times do we have to see it in the forum....Enough.....
    Its so frustrating giving the same link time and time again...And the funny
    part is that most people's questions has nothing to do with that. But
    still some geniuses give the same link....I just feel so sorry for people
    who are struggling to get a answer and some idiots give the same link

  • Use of titleKey attribute in html:select tag

    Hi,
    There is one "titleKey" attribute to create mouse over pop-up texts taking key values from property files in case of i18n. It works for every struts specific tag like <html:text titleKey="help.rmc.name"/> or <html:checkbox titleKey="help.rmc.name"/> except for <html:select> tag which is used for creating combo box or list box. But this tag contains the titleKey attribute.
    Please give me some suggestions how to implement this mouse over pop-up texts in case of <html:select> tag

    Hi,
    There is one "titleKey" attribute to create mouse over pop-up texts taking key values from property files in case of i18n. It works for every struts specific tag like <html:text titleKey="help.rmc.name"/> or <html:checkbox titleKey="help.rmc.name"/> except for <html:select> tag which is used for creating combo box or list box. But this tag contains the titleKey attribute.
    Please give me some suggestions how to implement this mouse over pop-up texts in case of <html:select> tag

Maybe you are looking for

  • How to change background color in photoshop cs3

    how to change background color in photoshop cs3 Please help me...

  • Apple feedback not working in safari

    I cannot submit Apple Feedback in Safari but I can in Firefox. The problem is that there is no Comments box. Does anyone else have this problem? And/or know how to solve it? I'm using safari 5.1 on OS X 10.6.8 Thanks, Tom

  • IPhone not displaying some PDF files in Mail

    We have a reporting server that generates PDF files sent by email. When I receive these files using Apple Mail on my Macbook or iMac, they are displayed without problems. However, when reading them in my email on the iPhone, the indicator just keeps

  • MacBook starts up for 1 second while sleeping

    Recently my MacBook has been starting up in it's sleep for a split second and then going back to sleep. What it does: The SuperDrive? makes that loud access sound The monitor flashes (when it's closed I can see it through the Apple logo). The fan beg

  • Multiple PR's for single sale order

    Hello all,    We are having Thrid party Scenario.For the sale order with multiple line items,single PR is created.    Is it possible to create PR for each line item in slae order? Regards, Shyam