Populating checkbox  with selected

I am trying to figure out how to display whether a user has selected an item in a checkbox. This requires two queries, one to get the locations and the second to check if the user has selected the location or not.
I just dont know how to loop through both of these queries to add "SELECTED" to the checkbox fields.
Code below only works if the user has selected one item previously. If more than one item, each location is listed twice, but the correct items are checked.
<%
String locations_query = "SELECT * FROM Client_Location WHERE Client_ID= '"+ Client_ID_form +"'";
ResultSet locations_myResultSet = stmt.executeQuery(locations_query);
         while (locations_myResultSet.next()) {
            String locations_Location_ID = locations_myResultSet.getString("Location_ID");
     %>
<%
String cust2_query = "SELECT Location_ID, Location_Name FROM Customer_Locations ORDER BY Location_Name";
ResultSet cust2_myResultSet = stmt.executeQuery(cust2_query);
         while (cust2_myResultSet.next()) {
           String Location_Name = cust2_myResultSet.getString("Location_Name");
           String Location_ID = cust_myResultSet.getString("Location_ID");
     %>
    <TR>
    <td align="right"></td>
    <TD><input type=checkbox value="<%=Location_ID%>" name="location_list"<%if(locations_Location_ID.equals(Location_ID)){%> checked<%}%>><%=Location_Name%></td>
    </tr>
     <%
       cust2_myResultSet.close();
%>
     <%
       locations_myResultSet.close();
%>Thank you for your time.

Not worked on jsp. however in java, a checkbox is either selected or not selected, so you can use checkboxitem.isSelected().

Similar Messages

  • Checkbox with select option

    Hi everyone,
    Is it possible to use checkbox and select option on the same variable?
    My requirement is for a variable which is a select option with no intervals, and along with that, I need to put a checkbox in the left hand side of the same field.
    Please suggest.

    Correct. I am not sure if you can achieve it without declaring a PARAMETER.
    selection-screen : begin of block blk1 with frame title text-001.
    selection-screen : begin of line.
    parameters       : p_chkbox as checkbox default 'X'.
    selection-screen : comment 5(15) text-002.
    selection-screen : position 21.
    select-options   : s_date for sy-datum no intervals.
    selection-screen : end of line.
    selection-screen : end of block blk1.
    Thanks,
    Pavan

  • How to retrive data from selected checkboxes with fieldnames

    hi experts,
    how to retrive data from selected checkboxes with fieldnames into another alv grid report.(here the fieldnames selected from  table names is dynamically).
    thankx in advance
    rani.k.

    Hi,
    Use user_command in the alv grid and then
    do the follwoing code
    FORM user_command1 USING lv_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    Declaration of local Variables
      DATA : lv_ref1 TYPE REF TO cl_gui_alv_grid.
      DATA lv_cnt TYPE i.                                    "+INS SUHESH 12.07.2008
    Check function code
      CASE lv_ucomm.
        WHEN 'ONLI'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              e_grid = lv_ref1.
          CALL METHOD lv_ref1->check_changed_data.
    now loop ur final internal table where check = 'X'.
    now pass data to other internal table..Now the internal table will be having values that the user selcetd on the screen.
    Hope this helps.
    Regards,
    Nagaraj

  • Adf Table with selection as set to NONE

    Hi,
    I having a scenario as explained below:
    I am populating records in to the adf Table
    After that I am using checkbox for selecting multiple records in the table and delete them.
    So I set selection property to None for the table. Because I want user to edit only that record which is checked.
    My multiple delete is working fine.
    Now if i selected one checkbox and and click on edit(which I have placed in the panal collection toolbar) it should show me the record in the which I have selected by check box. But it is showing me the first row.
    Can anybody help me to set the current row of the adf table manually which is having selection property as none. so that I can populate in popup.
    If some other way is available please explain.
    I am using jdeveloper 11.1.2.1
    Thanks,
    Sandeep.

    I don't see why you can't set selection property to "single"? (and don't forget to restore table SelectionListener property - if deleted)
    This will set current row when you click on it.
    If you programmatically iterate through RowSet to find rows with selected checkbox, this will work regardless of value in "selection" property.
    Dario
    Edited by: kdario on Nov 7, 2012 5:20 AM
    Edited by: kdario on Nov 7, 2012 5:22 AM

  • Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination

    Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination
    Problem in committing transactions in Multiple Forms (Oracle Forms) with POST built-in command:
    Consider that the following statements are written in WHEN-WINDOW-CLOSED trigger of a called form.
    Statements in called form (Form name: FORM_CHILD):
    go_block('display_block') ;
    do_key('execute_query') ;
    -- Data from table_b will be populated in this block, based on the value of COLUMN_1 obtained
    -- from TABLE_A.
    -- Example: If the value of COLUMN_1 is 10, then all the matching records from TABLE_B, which
    -- are inserted with value 10 in TABLE_B.COLUMN_1 will be fetched and shown here.
    if user_choice = 'YES' then
    commit ;
    else
    rollback ;
    end if ;
    Statements in calling forms:
    There are two calling forms having following statements and it is going to call the above said called form.
    CALLING FORM 1
    Statements in KEY-COMMIT trigger:
    post;
    call_form(form_child, no_activate) ;
    Statements in ON-INSERT trigger:
    select column_1
    from table_a
    for update of column_1
    where column_2 = 'X' ;
    update table_a
    set column_1 = column_1 + 1
    where column_2 = 'X' ;
    insert into table_b ...;
    insert into table_b ...; Statements in KEY-COMMIT trigger:
    post;
    call_form(form_child, no_activate) ;
    CALLING FORM 2:
    Statements in ON-INSERT trigger:
    select column_1
    from table_a
    for update of column_1
    where column_2 = 'X' ;
    update table_a
    set column_1 = column_1 + 1
    where column_2 = 'X' ;
    insert into table_b ...;
    insert into table_b ...;
    insert into table_b ...;
    Our understanding:
    Assume that both the forms are running from two different machines/instances, issuing commit at the same time. In this case, forms will start executing the statements written in ON-INSERT trigger, the moment POST command is executed. Though the commit is issued at the same time, according to oracle, only one of the request will be taken for processing first. Assume that calling form 1 is getting processed first.
    So, it fetches the value available in COLUMN_1 of TABLE_A and locks the row from further select, update, etc. as SELECT...FOR UPDATE command is used (note that NOWAIT is not given, hence the lock will be released only when COMMIT or ROLLBACK happens) and proceed executing further INSERT statements. Because of the lock provided by the SELECT...FOR UPDATE command, the statements in calling form 2 will wait for the resource.
    After executing the INSERT statements, the FORM_CHILD is called. The rows inserted in to TABLE_A will be queried and shown. The database changes will be committed when user closes the window (as COMMIT is issued in its WHEN-WINDOW-CLOSED trigger). Then the SELECT...FOR UPDATE lock will be released and calling form 2's statements will be executed.
    Actual happenings or Mis-behavior:
    Calling form 2 starts executing INSERT statements instead of waiting for SELECT...FOR UPDATE lock. Also, the value selected from TABLE_A.COLUMN_1 is same in both the calling forms, which is wrong.
    The rows inserted into TABLE_B are having similar COLUMN_1 values in calling form 2 and they are fetched and shown in the called form FORM_CHILD.
    Note that in calling form 2 also POST only is issued, but the changes posted there are accessible in calling form 1 also, which is wrong.
    Kindly suggest us as to how to fix above problem. It will be much use, if you can send us the information regarding the behavior of Oracle Forms POST built-in also.
    Our mail ID: [email protected]
    Thanks a lot in advance.

    You have several problems:
    1. On-Insert will ONLY run if you have created a new record in a base-table block. If you haven't done that, then the POST command will not cause it to run.
    2. Select for update without a "no wait" will lock records for the first form, but when the second form tries this, it will hit the ORA-00054 exception, and will NOT wait. The only way you could make it wait is to issue an UPDATE sql command, which is not such a good way to go.
    All POST does is issues SQL insert or update commands for any changes the user has made to records in a form's base-table blocks, without following with a Commit command.
    Also understand that Commit is the same as Commit_Form, and Rollback is the same as Clear_Form. You should read up on these in the Forms help topics.

  • Can I cause checking a box to add 1 to a calculated form field?  I have a field that sums the numbers entered in several previous fields and need to be able to add "1" if a checkbox is selected as well.

    Can I cause checking a box to add 1 to a calculated form field?  I have a field that sums the numbers entered in several previous fields and need to be able to add "1" if a checkbox is selected as well.

    I think it has something to do with the way the value of the check box is exported, but I'm not sure.  With nothing being exported to Data5, Data6 displays the sum of Data1-4 rounded down to the nearest whole number and updates automatically as Data1-4 are updated.
    Right now, assuming Data1-4 are 0, where data 5 is the output of the second example and any box is checked,  "1" is displayed in data5 but nothing is added to data 6. Selecting any other check box or deselecting that check box will cause data6 to add 1 even if data5 displays "0".  By way of example:
    Selecting Check box 16 results in Data5 displays 1 and Data6 displays zero.
    Then, if any or all of Checkbox17-20 are selected, Data5 displays 1 and Data6 displays 1.
    Then, if any or all of Checkbox17-20 are deselected, Data5 Displays 1 and Data6 displays1.
    Then, if Checkbox16 is deselected, Data5 displays 0 and Data6 displays 1.

  • Issue with selection screen

    Hi ,
    I had a custom program. There i have one parameter and one select option. But when i try clicking on multiple selections it is giving me a message in the status bar saying 'Place the cursor on a selection'. And it doesn't opens up the window to enter multiple selections.
    When i double clicked on the message i get the message no DB655.
    What can be the possible error for this ??
    Thanks & Regards,
    Anuj Srivastava

    Hi Anuj,
    I tried with the same code in ECC6.0 but i am able to get the multiple selection window.How it is not working for you?Do you maintain any conditions inside the logic.
    tables:USR02.
    SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-h08.      "LC006++
    PARAMETERS    : p_frggr LIKE ekko-frggr OBLIGATORY.
    SELECT-OPTIONS: s_class FOR usr02-class NO INTERVALS OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK 1.                                  "LC006++
    SELECTION-SCREEN SKIP 1.                                          "LC006++
    SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE text-h09.       "LC006++
    LC002++
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 40.
    PARAMETER: p_config AS CHECKBOX.
    SELECTION-SCREEN COMMENT 01(37) text-h05 FOR FIELD p_config.
    SELECTION-SCREEN END OF LINE.
    LC002++
    LC006++
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 40.
    PARAMETER: p_grptxt AS CHECKBOX.
    SELECTION-SCREEN COMMENT  01(37) text-h07 FOR FIELD p_grptxt.
    SELECTION-SCREEN END OF LINE.
    LC006++
    SELECTION-SCREEN END OF BLOCK 2.
    Thanks.
    Ramya.

  • How to checking my checkbox with a listbox

    I have a new form where I would like to check automatically my checkbox with a choice from listbox.
    I have a listbox with three values in french "Utilisateur" - "Comptable" and "Membre direction".
    I would like when the user has selected "Utilisateur", my checkbox with value "OJV_OFFICE_UTILISATEURS" has checked or "Comptable" checkbox with value "OJV_OPF Caissiers"
    Can you help me.
    Thanks

    Look at this previous post:
    https://forums.adobe.com/thread/1506686
    To modify the script to your form, you could try this as the custom validation script for your combo box:
    if (event.value=="Utilisateur") {
    this.getField("OJV_OFFICE_UTILISATEURS").value = "Yes"; 
    this.getField("OJV_OPF Caissiers").value = "No";}
    else if (event.value=="Comptable") {
    this.getField("OJV_OFFICE_UTILISATEURS").value = "No"; 
    this.getField("OJV_OPF Caissiers").value = "Yes";}
    Make sure you have the "Commit selected value immediately" option selected.

  • Uncheck a Checkbox when Select List Clicked

    version 4.0.2.00.06
    Hello,
    Jari helped me with a javascript function to select all options in a multi-select list when a checkbox is checked by the user.
    A bug was reported that after clicking the checkbox to select all the options in the list, if the user then clicks on a single value in the select list the checkbox is still checked.
    Would someone help me with how to uncheck the checkbox when a single value is selected in the select list after the checkbox is checked to select all of the options in the select list?
    If you need more information please let me know.
    Thanks,
    Joe

    Hi,
    Same sample as in this post
    Re: The requested URL /apex/wwv_flow.accept was not found on this server
    I did add page JavaScript
    function checkSelected(pThis,pChk,pVal){
    var self=$($x(pThis));
    var o=self.find("option");
    var s=self.find("option:selected");
    if(s.length==o.length){
      $s(pChk,pVal);
    }else{
      $s(pChk,"");
    }And to P65_EMP multiu select HTML Form Element Attributes
    onchange="checkSelected(this,'P67_SELECT_ALL','ALL')"Regards,
    Jari

  • Checkbox with JTree

    hai,
    i added checkbox to each tree node and my coding is
    import java.awt.BasicStroke;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.ComponentOrientation;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.RenderingHints;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.util.Arrays;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    import javax.swing.AbstractAction;
    import javax.swing.AbstractButton;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.KeyStroke;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.TreeCellRenderer;
    import javax.swing.tree.TreePath;
    /** Provides checkbox-based selection of tree nodes. Override the protected
    * methods to adapt this renderer's behavior to your local tree table flavor.
    * No change listener notifications are provided.
    public class CheckBoxTreeCellRenderer implements TreeCellRenderer {
    public static final int UNSELECTABLE = 0;
    public static final int FULLSELECTED = 1;
    public static final int NOTSELECTED = 2;
    public static final int PARTIALSELECTED = 3;
    private TreeCellRenderer renderer;
    public static JCheckBox checkBox;
    private Point mouseLocation;
    private int mouseRow = -1;
    private int pressedRow = -1;
    private boolean mouseInCheck;
    private int state = NOTSELECTED;
    private Set checkedPaths;
    private JTree tree;
    private MouseHandler handler;
    /** Create a per-tree instance of the checkbox renderer. */
    public CheckBoxTreeCellRenderer(JTree tree, TreeCellRenderer original) {
    this.tree = tree;
    this.renderer = original;
    checkedPaths = new HashSet();
    checkBox = new JCheckBox();
    checkBox.setOpaque(false);
    System.out.println(checkBox.isSelected());
    checkBox.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
              trace(checkBox);
    // ActionListener actionListener = new ActionListener() {
    // public void actionPerformed(ActionEvent actionEvent) {
    // AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
    // boolean selected = abstractButton.getModel().isSelected();
    // System.out.println(selected);
    // // abstractButton.setText(newLabel);
    // checkBox.addActionListener(new ActionListener(){
    //               public void actionPerformed(ActionEvent actionEvent) {
    //                    Checkbox cb = actionEvent.getSource();
    //     boolean selected = abstractButton.getModel().isSelected();
    //     System.out.println(selected);
    checkBox.setSize(checkBox.getPreferredSize());
    private static void trace(JCheckBox cb) {
         if (cb.isSelected())
              System.out.println(cb.getText()+" is " + cb.isSelected());
         else
              System.out.println(cb.getText()+" is " + cb.isSelected());
    protected void installMouseHandler() {
    if (handler == null) {
    handler = new MouseHandler();
    addMouseHandler(handler);
    protected void addMouseHandler(MouseHandler handler) {
    tree.addMouseListener(handler);
    tree.addMouseMotionListener(handler);
    private void updateMouseLocation(Point newLoc) {
    if (mouseRow != -1) {
    repaint(mouseRow);
    mouseLocation = newLoc;
    if (mouseLocation != null) {
    mouseRow = getRow(newLoc);
    repaint(mouseRow);
    else {
    mouseRow = -1;
    if (mouseRow != -1 && mouseLocation != null) {
    Point mouseLoc = new Point(mouseLocation);
    Rectangle r = getRowBounds(mouseRow);
    if (r != null)
    mouseLoc.x -= r.x;
    mouseInCheck = isInCheckBox(mouseLoc);
    else {
    mouseInCheck = false;
    protected int getRow(Point p) {
    return tree.getRowForLocation(p.x, p.y);
    protected Rectangle getRowBounds(int row) {
    return tree.getRowBounds(row);
    protected TreePath getPathForRow(int row) {
    return tree.getPathForRow(row);
    protected int getRowForPath(TreePath path) {
    return tree.getRowForPath(path);
    public void repaint(Rectangle r) {
    tree.repaint(r);
    public void repaint() {
    tree.repaint();
    private void repaint(int row) {
    Rectangle r = getRowBounds(row);
    if (r != null)
    repaint(r);
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    installMouseHandler();
    TreePath path = getPathForRow(row);
    state = UNSELECTABLE;
    if (path != null) {
    if (isChecked(path)) {
    state = FULLSELECTED;
    else if (isPartiallyChecked(path)) {
    state = PARTIALSELECTED;
    else if (isSelectable(path)) {
    state = NOTSELECTED;
    checkBox.setSelected(state == FULLSELECTED);
    checkBox.getModel().setArmed(mouseRow == row && pressedRow == row && mouseInCheck);
    checkBox.getModel().setPressed(pressedRow == row && mouseInCheck);
    checkBox.getModel().setRollover(mouseRow == row && mouseInCheck);
    Component c = renderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    checkBox.setForeground(c.getForeground());
    if (c instanceof JLabel) {
    JLabel label = (JLabel)c;
    // Augment the icon to include the checkbox
    Icon customOpenIcon = new ImageIcon("browse.gif");
    label.setIcon(new CompoundIcon(label.getIcon()));
    return c;
    private boolean isInCheckBox(Point where) {
    Insets insets = tree.getInsets();
    int right = checkBox.getWidth();
    int left = 0;
    if (insets != null) {
    left += insets.left;
    right += insets.left;
    return where.x >= left && where.x < right;
    public boolean isExplicitlyChecked(TreePath path) {
    return checkedPaths.contains(path);
    /** Returns whether selecting the given path is allowed. The default
    * returns true. You should return false if the given path represents
    * a placeholder for a node that has not yet loaded, or anything else
    * that doesn't represent a normal, operable object in the tree.
    public boolean isSelectable(TreePath path) {
    return true;
    /** Returns whether the given path is currently checked. */
    public boolean isChecked(TreePath path) {
    if (isExplicitlyChecked(path)) {
    return true;
    else {
    if (path.getParentPath() != null) {
    return isChecked(path.getParentPath());
    else {
    return false;
    public boolean isPartiallyChecked(TreePath path) {
    Object node = path.getLastPathComponent();
    for (int i = 0; i < tree.getModel().getChildCount(node); i++) {
    Object child = tree.getModel().getChild(node, i);
    TreePath childPath = path.pathByAddingChild(child);
    if (isChecked(childPath) || isPartiallyChecked(childPath)) {
    return true;
    return false;
    private boolean isFullyChecked(TreePath parent) {
    Object node = parent.getLastPathComponent();
    for (int i = 0; i < tree.getModel().getChildCount(node); i++) {
    Object child = tree.getModel().getChild(node, i);
    TreePath childPath = parent.pathByAddingChild(child);
    if (!isExplicitlyChecked(childPath)) {
    return false;
    return true;
    public void toggleChecked(int row) {
    TreePath path = getPathForRow(row);
    boolean isChecked = isChecked(path);
    removeDescendants(path);
    if (!isChecked) {
    checkedPaths.add(path);
    setParent(path);
    repaint();
    private void setParent(TreePath path) {
    TreePath parent = path.getParentPath();
    if (parent != null) {
    if (isFullyChecked(parent)) {
    removeChildren(parent);
    checkedPaths.add(parent);
    } else {
    if (isChecked(parent)) {
    checkedPaths.remove(parent);
    addChildren(parent);
    checkedPaths.remove(path);
    setParent(parent);
    private void addChildren(TreePath parent) {
    Object node = parent.getLastPathComponent();
    for (int i = 0; i < tree.getModel().getChildCount(node); i++) {
    Object child = tree.getModel().getChild(node, i);
    TreePath path = parent.pathByAddingChild(child);
    checkedPaths.add(path);
    private void removeChildren(TreePath parent) {
    for (Iterator i = checkedPaths.iterator(); i.hasNext();) {
    TreePath p = (TreePath) i.next();
    if (p.getParentPath() != null && parent.equals(p.getParentPath())) {
    i.remove();
    private void removeDescendants(TreePath ancestor) {
    for (Iterator i = checkedPaths.iterator(); i.hasNext();) {
    TreePath path = (TreePath) i.next();
    if (ancestor.isDescendant(path)) {
    i.remove();
    /** Returns all checked rows. */
    public int[] getCheckedRows() {
    TreePath[] paths = getCheckedPaths();
    int[] rows = new int[checkedPaths.size()];
    for (int i = 0; i < checkedPaths.size(); i++) {
    rows[i] = getRowForPath(paths);
    Arrays.sort(rows);
    return rows;
    /** Returns all checked paths. */
    public TreePath[] getCheckedPaths() {
    return (TreePath[]) checkedPaths.toArray(new TreePath[checkedPaths.size()]);
    protected class MouseHandler extends MouseAdapter implements MouseMotionListener {
    public void mouseEntered(MouseEvent e) {
    updateMouseLocation(e.getPoint());
    public void mouseExited(MouseEvent e) {
    updateMouseLocation(null);
    public void mouseMoved(MouseEvent e) {
    updateMouseLocation(e.getPoint());
    public void mouseDragged(MouseEvent e) {
    updateMouseLocation(e.getPoint());
    public void mousePressed(MouseEvent e) {
    pressedRow = e.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK
    ? getRow(e.getPoint()) : -1;
    updateMouseLocation(e.getPoint());
    public void mouseReleased(MouseEvent e) {
    if (pressedRow != -1) {
    int row = getRow(e.getPoint());
    if (row == pressedRow) {
    Point p = e.getPoint();
    Rectangle r = getRowBounds(row);
    p.x -= r.x;
    if (isInCheckBox(p)) {
    toggleChecked(row);
    pressedRow = -1;
    updateMouseLocation(e.getPoint());
    public void mouseClicked(MouseEvent e){
         if(checkBox.isSelected()){
              System.out.println(checkBox.getName());
    /** Combine a JCheckBox's checkbox with another icon. */
    private final class CompoundIcon implements Icon {
    private final Icon icon;
    private final int w;
    private final int h;
    private CompoundIcon(Icon icon) {
    if (icon == null) {
    icon = new Icon() {
    public int getIconHeight() { return 0; }
    public int getIconWidth() { return 0; }
    public void paintIcon(Component c, Graphics g, int x, int y) { }
    this.icon = icon;
    this.w = icon.getIconWidth();
    this.h = icon.getIconHeight();
    public int getIconWidth() {
    return checkBox.getPreferredSize().width + w;
    public int getIconHeight() {
    return Math.max(checkBox.getPreferredSize().height, h);
    public void paintIcon(Component c, Graphics g, int x, int y) {
    if (c.getComponentOrientation().isLeftToRight()) {
    int xoffset = checkBox.getPreferredSize().width;
    int yoffset = (getIconHeight()-icon.getIconHeight())/2;
    icon.paintIcon(c, g, x + xoffset, y + yoffset);
    if (state != UNSELECTABLE) {
    paintCheckBox(g, x, y);
    else {
    int yoffset = (getIconHeight()-icon.getIconHeight())/2;
    icon.paintIcon(c, g, x, y + yoffset);
    if (state != UNSELECTABLE) {
    paintCheckBox(g, x + icon.getIconWidth(), y);
    private void paintCheckBox(Graphics g, int x, int y) {
    int yoffset;
    boolean db = checkBox.isDoubleBuffered();
    checkBox.setDoubleBuffered(false);
    try {
    yoffset = (getIconHeight()-checkBox.getPreferredSize().height)/2;
    g = g.create(x, y+yoffset, getIconWidth(), getIconHeight());
    checkBox.paint(g);
    if (state == PARTIALSELECTED) {
    final int WIDTH = 2;
    g.setColor(UIManager.getColor("CheckBox.foreground"));
    Graphics2D g2d = (Graphics2D)g;
    g2d.setStroke(new BasicStroke(WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int w = checkBox.getWidth();
    int h = checkBox.getHeight();
    g.drawLine(w/4+2, h/2-WIDTH/2+1, w/4+w/2-3, h/2-WIDTH/2+1);
    g.dispose();
    finally {
    checkBox.setDoubleBuffered(db);
    private static String createText(TreePath[] paths) {
    if (paths.length == 0) {
    return "Nothing checked";
    String checked = "Checked:\n";
    for (int i=0;i < paths.length;i++) {
    checked += paths[i] + "\n";
    return checked;
    public static void main(String[] args) {
    try {
    final String SWITCH = "toggle-componentOrientation";
    try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (ClassNotFoundException e1) {
                   e1.printStackTrace();
              } catch (InstantiationException e1) {
                   e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                   e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                   e1.printStackTrace();
    JFrame frame = new JFrame("Tree with Check Boxes");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final DefaultMutableTreeNode a = new DefaultMutableTreeNode("Node 1");
    for(int i =0 ; i<3; i++ ){
         DefaultMutableTreeNode b = new DefaultMutableTreeNode("ChildNode "+i);
         a.add(b);
    DefaultMutableTreeNode e = new DefaultMutableTreeNode("Node 2");
    for(int i =0 ; i<3; i++ ){
         DefaultMutableTreeNode f = new DefaultMutableTreeNode("ChildNode "+i);
         e.add(f);
    DefaultMutableTreeNode al = new DefaultMutableTreeNode("Sample");
    al.add(a);
    al.add(e);
    final JTree tree = new JTree(al);
    final CheckBoxTreeCellRenderer r =
    new CheckBoxTreeCellRenderer(tree, tree.getCellRenderer());
    tree.setCellRenderer(r);
    int rc = tree.getRowCount();
    tree.getActionMap().put(SWITCH, new AbstractAction(SWITCH) {
    public void actionPerformed(ActionEvent e) {
    ComponentOrientation o = tree.getComponentOrientation();
    if (o.isLeftToRight()) {
    o = ComponentOrientation.RIGHT_TO_LEFT;
    else {
    o = ComponentOrientation.LEFT_TO_RIGHT;
    tree.setComponentOrientation(o);
    tree.repaint();
    int mask = InputEvent.SHIFT_MASK|Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    tree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_O, mask), SWITCH);
    final JTextArea text = new JTextArea(createText(r.getCheckedPaths()));
    text.setPreferredSize(new Dimension(200, 100));
    tree.addMouseListener(new MouseAdapter() {
    public void mouseReleased(MouseEvent e) {
    // Invoke later to ensure all mouse handling is completed
    SwingUtilities.invokeLater(new Runnable() { public void run() {
    text.setText(createText(r.getCheckedPaths()));
    JScrollPane pane = new JScrollPane(tree);
    frame.getContentPane().add(pane);
    // frame.getContentPane().add(new JScrollPane(text), BorderLayout.SOUTH);
    frame.pack();
    frame.setSize(600,400);
    frame.setVisible(true);
    catch(Exception e) {
    e.printStackTrace();
    System.exit(1);
    now i need to get nodes names which has been selected, how can i do this
    can anyone help me ...
    regards,
    shobi

    Also, use code tags and post a SSCCE -- I'm sure more of your posted code is irrelevant to your question and few people are going to look at a code listing that long.
    [http://mindprod.com/jgloss/sscce.html]

  • Javascript to check if a checkbox is selected in datatable

    Hi,
    I have a form with some command buttons and couple of datatables with checkboxes in one of the columns. How do I make sure when a user clicks on any command button to generate an action only if any checkbox is selected else shows an error to atleast select one checkbox. Is it possible do that using javascript rather than on the server side. Any small example will help.
    Thanks

    Hi Detlev,
    I searched for the file controls_ie5.js. But I have only one function for cell click in js file. I didnt get any methods you mentioned in the reply.
    The workaround I could see is, get the name of the tableview control using 'myContext.getParamIdForComponent("tableviewcontrolname")'. Then append '-chk'(that is the name generated dynamically for the radio button in the HTML page). With this we can do a javascript validation if a radio button is selected. The only disadvantage is if they change the naming conventions(say instead of -chk if they use _chk) for HTMLB implementation this code will fail.
    In another post I saw a reply from Stephan Batzdorf for similar post. He says, "Now to the client side. The only thing you can do on client-side is to retrieve the selected rows and get the values from the key column.
    It's not possible to manipulate data. Of course you can render InputFields into table cells and let the user manipulate them, but then you have to retrieve each value for each InputField again on server side (pageContext.getComponentForId(tableCellInputFieldId);)."
      Does he say we cant get the value of inputfield in the client side?
    I will definitely award points once the problem is fixed.
    Regards,
    Priya

  • Single checkbox not selected

    I know this is not a javscript forum.. (WISH THERE WAS ONE On SUN.COM)..and i am sorry to post it here.. but the problem is JSP and javascript
    I have multiple checboxes.. Something like Yahoo mail.. When the inbox is opened the number of checkboxes correspond to the number of mails on that page..along with an extra one at the very top(called it Header_checkbox).. If header_checkbox is selected.. all the mails are selected and one can either delete or move the mails..
    My form is kinda similar.. I have multiple rows.. and depending on the number of rows, the checkboxes are displayed.. the Javascript function works fine if there are more than one checkboxes...It doesnt work if theres a single one.. well not a big deal since the user can click on the single checkbox and it shld be fine.. but i am curious to know why it isnt working for a single one. When i try to display the checkbox.length it gives me "undefined" (this is incase theres only one chekcbox)... for multiple chekcboxes it gives the rite number.
    Heres the code if anyone has suggestions
    Thank you
    function toggle(frm)
       var checkbox_length = frm.checks.length;
        alert(checkbox_length);
       for( var i = 0; i < checkbox_length; i++ )
          frm.checks.checked = frm.tog.checked;
    [HTML CODE]
    <FORM name="editFormatForm" method="post" action="edit_delete_filetype_format.jsp">
    <tr class="titleitem">
    <td><input type="checkbox" name="tog" onclick="javascript:toggle(this.form);"></td>
    <td>Fieldname��</td>
    <td>Format��</td>
    <td>Unique?</td>
    <td>Optional?</td>
    <td>Description</td>
    <td></td><td></td>
    </tr>
    <%
    if (fileTypeList.size() > 0)
    for (int k = 0; k < fileTypeList.size(); k++)
    formatObject = (FiletypeFormatObject) fileTypeList.get(k);
    id = formatObject.getId();
    columnName = formatObject.getColumnName();
    columnFormat = formatObject.getColumnFormat();
    uniqueness = formatObject.getColumnUnique();
    description = formatObject.getDescription();
    optional_int = formatObject.getColumnOptional();
    count++;
    %>
    <tr class="<%=htmlObj.getClassString(count)%>">
    <td><input type="checkbox" name="checks" value="<%=id%>"></td>
    <td><input type="text" name="columnName" value="<%=columnName%>"></td>
    <td><input type="text" name="columnFormat" size='30' value="<%=columnFormat%>"></td>
    <td><input type="checkbox" name="unique" <% if(uniqueness == 1) { %> checked <%}%>></td>
    <td><input type="checkbox" name="optional" <% if (optional_int == 1) { %> checked <%} %>></td>
    <td><input type="text" name="description" value="<%=description%>"></td>
    </tr>
    <% } } count++; %>
    <tr class="<%=htmlObj.getClassString(count)%>"><td></td><td><input type="submit" value="Submit Changes"></td>
    <td colspan="12"><input type="submit" value="delete"></td></tr>
    <% count++; %>
    <tr class="<%=htmlObj.getClassString(count)%>"><td></td><td colspan="12">�</td></tr>
    <% count++; %>
    <tr class="<%=htmlObj.getClassString(count)%>"><td></td><td><input value="Enter New Field..."></td>
    <td><input value=""></td><td><input type="checkbox"></td><td><input type="checkbox"></td>
    <td><input type="submit" value="Add Field"></td><td></td></tr>
    </FORM>
    [END OF HTML CODE]

    The browser creates a DOM (Document Object Model) of the document and the elements in the document. In this DOM it references the elements on the page by name. If there is more than one element with the same name it creates an array of these elements and puts the array in the DOM but if there is only one element it places this element in the array.
    If there is only one checkbox with the name "checks" this will be the object referred to as "rm.checks" and this element doesn't have an length property.
    function toggle(frm)
    var checkbox_length = frm.checks.length;
    if (checkbox_length != undefined) {
        for( var i = 0; i < checkbox_length; i++ )
           frm.checks.checked = frm.tog.checked;
    } else {
    frm.checks.checked = frm.tog.checked;

  • SUBMIT ......WITH SELECTION-TABLE

    Dear All,
    I am using the following statement to send report to spool:
    SUBMIT riafvc20  TO SAP-SPOOL
          SPOOL PARAMETERS K_PARAMS
          WITHOUT SPOOL DYNPRO AND RETURN WITH SELECTION-TABLE seltab.
    When I read the contents from the spool, I get the records only pertaining to first record in seltab. Any insights on why this is happening.
    Note: seltab is an internal table without a header line.
    Thanks in Advance,
    Rajesh

    seltab was populated using the following statement.
    LOOP AT i_order.
      MOVE: 'AUFNR'  TO seltab_wa-selname,
            'S'      TO seltab_wa-kind,      " SELECT-OPTION
            'I'      TO seltab_wa-sign,
            'EQ'     TO seltab_wa-option,
            i_order-aufnr  TO seltab_wa-low,
            ' '     TO seltab_wa-high.
      APPEND seltab_wa TO seltab.
      ENDLOOP.
    Below is the code of the program. Please note that there are 2 submit statements, the first one is working fine, but not the second submit statement.
    FUNCTION Z_TEST_REPAIR.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(P_AUART) LIKE  DIAUFK-AUART
    *"  TABLES
    *"      T_OUTPUT STRUCTURE  ZLINE
    DATA: i_list LIKE abaplist OCCURS 0 WITH HEADER LINE.
      DATA: BEGIN OF i_list_conv OCCURS 1,
              line(256),
            END OF i_list_conv.
    DATA : BEGIN OF I_SPOOL OCCURS 0,
              RQIDENT LIKE TSP01-RQIDENT,
           END OF I_SPOOL.
    DATA : I_ACTUAL      LIKE SOLI OCCURS 0 WITH HEADER LINE.
      DATA: BEGIN OF i_order OCCURS 0,
              aufnr LIKE aufk-aufnr,
            END OF i_order.
      DATA: seltab     TYPE TABLE OF rsparams,
            seltab_wa  LIKE LINE OF seltab.
      RANGES: r_aufnr FOR aufk-aufnr.
      DATA: v_lines TYPE i.
      DATA : K_PARAMS      LIKE PRI_PARAMS,
             V_JOBCOUNT LIKE TBTCM-JOBCOUNT,
             V_SPOOL_NO LIKE  TSP01-RQIDENT,    "SPOOL NO.
             V_LIST LIKE PRI_PARAMS-PLIST.
      MOVE: 'AUART'  TO seltab_wa-selname,
            'S'      TO seltab_wa-kind,      " SELECT-OPTION
            'I'      TO seltab_wa-sign,
            'EQ'     TO seltab_wa-option,
            p_auart  TO seltab_wa-low,
            ' '      TO seltab_wa-high.
      APPEND seltab_wa TO seltab.
    MOVE: 'AUART'  TO seltab_wa-selname,
           'S'      TO seltab_wa-kind,      " SELECT-OPTION
           'I'      TO seltab_wa-sign,
           'EQ'     TO seltab_wa-option,
           'Z001'  TO seltab_wa-low,
           ' '      TO seltab_wa-high.
    APPEND seltab_wa TO seltab.
        CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
             IMPORTING
                  JOBCOUNT        = V_JOBCOUNT
             EXCEPTIONS
                  NO_RUNTIME_INFO = 1
                  OTHERS          = 2.
        IF SY-SUBRC <> 0.
        ENDIF.
        CONCATENATE 'ACT' V_JOBCOUNT INTO V_LIST.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
         EXPORTING
              LIST_NAME      = V_LIST
              NO_DIALOG      = 'X'
         IMPORTING
              OUT_PARAMETERS = K_PARAMS.
       SUBMIT riaufk20 TO SAP-SPOOL
                      SPOOL PARAMETERS K_PARAMS
                      WITHOUT SPOOL DYNPRO AND RETURN WITH SELECTION-TABLE seltab.
    This select neither goes by primary nor any index as we are passing
    rq2name which is not a part of primary or any index
      SELECT RQIDENT FROM TSP01 INTO TABLE I_SPOOL WHERE RQ2NAME = V_LIST.
      IF SY-SUBRC = 0.
        SORT I_SPOOL BY RQIDENT DESCENDING.
        READ TABLE I_SPOOL INDEX 1.
        V_SPOOL_NO = I_SPOOL-RQIDENT.
      ENDIF.
      CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
           EXPORTING
                RQIDENT              = V_SPOOL_NO
                DESIRED_TYPE         = 'RAW'
           TABLES
                BUFFER               = I_ACTUAL
           EXCEPTIONS
                NO_SUCH_JOB          = 1
                JOB_CONTAINS_NO_DATA = 2
                SELECTION_EMPTY      = 3
                NO_PERMISSION        = 4
                CAN_NOT_ACCESS       = 5
                READ_ERROR           = 6
                TYPE_NO_MATCH        = 7
                OTHERS               = 8.
      IF SY-SUBRC <> 0.
      ENDIF.
    *====================================================================
      DATA: v_text1(20).
      LOOP AT I_ACTUAL.
        IF sy-tabix GT 3.
          SPLIT I_ACTUAL-line AT '|' INTO v_text1 I_ACTUAL-line.
          SPLIT I_ACTUAL-line AT '|' INTO v_text1 I_ACTUAL-line.
          SPLIT I_ACTUAL-line AT '|' INTO i_order-aufnr I_ACTUAL-line.
          APPEND i_order.
          CLEAR  i_order.
        ENDIF.
      ENDLOOP.
    IF NOT I_ORDER[] IS INITIAL.
      DESCRIBE TABLE i_order LINES v_lines.
      DELETE i_order INDEX v_lines.
    ENDIF.
      REFRESH seltab.
      CLEAR   seltab_wa.
      REFRESH i_list.
      REFRESH i_list_conv.
      SORT i_order.
      LOOP AT i_order.
      MOVE: 'AUFNR'  TO seltab_wa-selname,
            'S'      TO seltab_wa-kind,      " SELECT-OPTION
            'I'      TO seltab_wa-sign,
            'EQ'     TO seltab_wa-option,
            i_order-aufnr  TO seltab_wa-low,
            ' '     TO seltab_wa-high.
      APPEND seltab_wa TO seltab.
      ENDLOOP.
    *========================================================================
      Refresh: I_SPOOL, I_ACTUAL.
      clear:   V_JOBCOUNT, V_LIST, V_SPOOL_NO, K_PARAMS.
       CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
             IMPORTING
                  JOBCOUNT        = V_JOBCOUNT
             EXCEPTIONS
                  NO_RUNTIME_INFO = 1
                  OTHERS          = 2.
        IF SY-SUBRC <> 0.
        ENDIF.
        CONCATENATE 'ACT' V_JOBCOUNT INTO V_LIST.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
         EXPORTING
              LIST_NAME      = V_LIST
              NO_DIALOG      = 'X'
         IMPORTING
              OUT_PARAMETERS = K_PARAMS.
    *DATA: RANGE_LANGU    TYPE RANGE OF aufk-aufnr,
         RANGE_LANGU_WA LIKE lINE OF RANGE_LANGU.
    LOOP AT i_order.
    MOVE:
           'I'      TO RANGE_LANGU_WA-sign,
           'EQ'     TO RANGE_LANGU_WA-option,
           i_order-aufnr  TO RANGE_LANGU_WA-low,
           ' '     TO RANGE_LANGU_WA-high.
    APPEND RANGE_LANGU_WA TO RANGE_LANGU.
    endloop.
       SUBMIT riafvc20  TO SAP-SPOOL
                      SPOOL PARAMETERS K_PARAMS
                      WITHOUT SPOOL DYNPRO AND RETURN WITH SELECTION-TABLE seltab.
                     via selection-screen.
    This select neither goes by primary nor any index as we are passing
    rq2name which is not a part of primary or any index
      SELECT RQIDENT FROM TSP01 INTO TABLE I_SPOOL WHERE RQ2NAME = V_LIST.
      IF SY-SUBRC = 0.
        SORT I_SPOOL BY RQIDENT DESCENDING.
        READ TABLE I_SPOOL INDEX 1.
        V_SPOOL_NO = I_SPOOL-RQIDENT.
      ENDIF.
      CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
           EXPORTING
                RQIDENT              = V_SPOOL_NO
                DESIRED_TYPE         = 'RAW'
           TABLES
                BUFFER               = I_ACTUAL
           EXCEPTIONS
                NO_SUCH_JOB          = 1
                JOB_CONTAINS_NO_DATA = 2
                SELECTION_EMPTY      = 3
                NO_PERMISSION        = 4
                CAN_NOT_ACCESS       = 5
                READ_ERROR           = 6
                TYPE_NO_MATCH        = 7
                OTHERS               = 8.
      IF SY-SUBRC <> 0.
      ENDIF.
      t_output[] = I_ACTUAL[].
    ENDFUNCTION.

  • Checkbox with 3 states?

    Hi,
    is there any way in jsf to create checkboxes with more than two states?
    Something like
    -true (e.g. value 2)
    -false (e.g. value 0)
    -something in between (e.g. value 1)
    You need those when you select a group of features and deselect one of the features (e.g. installation of software, see installshield). The checkbox usually is still selected, but with a shady gray background. You can see if the whole group of features is selected, if the whole group is deselected or if some features of the group are selected.
    Is there a way to get those components without having to create them manually? I can't believe nobody else needs those.
    Greetings, jimbo

    Hi Paul,
    It adds the value, how would I (add enter) so the text are seperate lines.
    Example 1:
    The dog is in the dog house. The cat is in a tree. (bad)
    Example 2:
    The dog is in the dog house.
    The cat is in the tree
    Viewing the text as in Example 2 is easier to read.
    Thank You,
    Arnold

  • Checkbox with submit

    Hi,
    Is there checkboxes with submit/redirect in APEX 3.2 / 4.0? I'm using 3.0 and there's no option :(
    Is there an alternative I can do? Maybe something like Form Element Option Attributes - onclick=refresh()/reload() except I need it to recognise in the session that the checkbox is selected (it remains selected with some options but item conditions dont occur and it doesnt recognise the checkbox's value in the session section.
    Mike
    Edited by: Dird on May 7, 2010 2:38 PM

    Hi Mike
    onclick=doSubmit('YOUR_REQUEST_VALUE');In the HTML Form Element Attributes should do it.
    I don't know about 4.0 but it's not in 3.2.1.
    Cheers
    Ben

Maybe you are looking for

  • Can we combine or link Apple IDs?

    My wife and I both have different Apple IDs (from before we were married) and it is kind of a nuisance given that we share all the music on our two computers. Is there a way to combine or link multiple IDs to one account?

  • Lightroom 3's "edit in photoshop CS4" does not preserve "detail" values

    Hi all, I am giving lightroom 3 a try (finally...), but noticed that when I have an image to which I have applied "detail" adjustments to reduce luminescence and color noise, using "edit in Photoshop CS4" opens the image without the detail adjustment

  • BI : Trigger Job

    Hi Experts, I need to create a job which wil trigger at Last monday of fiscal month. I found FM which will do that work. I want to know is there any table in BI from where i can derive the date of last monday and trigger the job. Kindly advise. thank

  • How can i get the 4.01 upgrade for Final Cut Express 4.01

    I have problems importing movieclips from my Sony HD camcorder (Sony HDR-CX350VE) in Final Cut Express. Surfing some Mac forums I jumped to the conclusion that I am not the only one. FCE sees the clips, but when I try to import them I get an error (i

  • Can i keep my music files on an external hard drive and somehow sync the songs from there?

    I have just purchased a new mac book pro, but don't want to fill up all it's memory with music files that i have on my external hard drive. Is there a way that i can keep the files on the external hard drive without having to upload them onto my comp