Binding a boolean value to a Checkbox in Dashcode

I can't seem to bind a boolean value in my JSON model to a checkbox in Dashcode. I can create the binding, and it shows up properly in the datasource and in the bindings inspector for the checkbox part, but if I launch the application through the simulator, or if I save the project, the binding disappears.
To reproduce:
1. create an empty (custom) web application project.
2. Drag a checkbox part onto the canvas.
3. Create a datasource with the JSON model:
doit: "false"
4. Load the datasource, and drag a binding from the doit boolean field to the checkbox. The binding is created. Save the project. The binding is gone.
Anyone else seen this? What am I doing wrong?

happybuddha wrote:
The question really is, if my pojo has lets say 10 setter methods which will set a boolean to variables in the class. Is there a way I can pass a boolean parameter to 9 out of 10 setters (since the 10th one will be true)?
Or to all setters is also fine I can then set the one I am interested to true. In case the properties of your PoJOs are <tt>boolean</tt> (and not <tt>Boolean</tt>) they get initialized to false on Object creation.
bye
TPD

Similar Messages

  • JTable cell color overriding Boolean values displayed as checkboxes. Fix?

    I have a JTable column of Boolean values that automatically appear as checkboxes. When I apply my DefaultTableCellRenderer to this column, the checkbox disappears and a "false" or "true" appears instead. But if I mouseclick on the cell, the checkbox will appear momentarily.
    Any suggestions for getting the Boolean value displayed as a checkbox and seeing my colors change? (I suppose the easy way is using JCheckBox, but I'm curious if I can do it using Boolean)
    Thanks for the help. Code follows for the cell renderer.
    class ColorRenderer extends DefaultTableCellRenderer{
    public ColorRenderer() {
    super();
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected == true) {
      setBackground(Color.getHSBColor(100, 100, 1));
      setForeground(Color.BLACK);
    } else {
      setBackground(Color.LIGHT_GRAY);
      setForeground(Color.WHITE);
    if (hasFocus == true) {
      setBackground(Color.RED);
      setForeground(Color.WHITE);
    setOpaque(true);
    setValue(value);
    return this;

    Wouldn't extend DefaultTableCellRenderer as that extends a JLabel
    I would extend a JCheckBox and implement TableCellRenderer.

  • Getting the value of a checkbox in an item renderer?

    I have a list that uses an item renderer with buttons and data.  I need to add a checkbox and get the value of this checkbox passed along with the event of the pushbutton.
    When the user clicks "add to menu: there is a click handler:
    protected function addButton_clickHandler(event:MouseEvent):void
                        doubleIt = double.selected;
                        owner.dispatchEvent(new Event("ADD_TO_MENU", true));
    Back in the main application, there is a listener for this event.  I want that handler to be able to "know" the status of that checkbox (i.e. the value of "doubleIt", defined as a public boolean).
    private function addToMenuHandler(event:Event):void {
               var i:int = event.target.selectedIndex;
               var obj:Object = new Object();
               obj = recipeListCollection.getItemAt(i);
               menuList += obj;
    I have tried various permutations of the event.target, but can't figure out how to access that variable.

    Create a custom event and stuff anything you want in there.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Cell with boolean value not rendering properly in Swing (custom renderer)

    Hello All,
    I have a problem rendenring boolean values when using a custom cell renderer inside a JTable; I managed to reproduce the issue with a dummy application. The application code follows:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.lang.reflect.InvocationTargetException;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import java.util.logging.Logger;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    * Simple GUI that uses custom cell rendering
    * @author josevnz
    public final class SimpleGui extends JFrame {
         private static final long serialVersionUID = 1L;
         private Logger log = Logger.getLogger(SimpleGui.class.getName());
         private JTable simpleTable;
         public SimpleGui() {
              super("Simple GUI");
              setPreferredSize(new Dimension(500, 500));
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLayout(new BorderLayout());
         public void constructGui() {
              simpleTable = new JTable(new SimpleTableModel());
              simpleTable.getColumnModel().getColumn(2).setCellRenderer(new HasItCellRenderer());
              SpecialCellRenderer specRen = new SpecialCellRenderer(log);
              simpleTable.setDefaultRenderer(Double.class, specRen);
              simpleTable.setDefaultRenderer(String.class, specRen);
              simpleTable.setDefaultRenderer(Date.class, specRen);
              //simpleTable.setDefaultRenderer(Boolean.class, specRen);
              add(new JScrollPane(simpleTable), BorderLayout.CENTER);          
              pack();
              setVisible(true);
         private void populate() {
              List <List<Object>>people = new ArrayList<List<Object>>();
              List <Object>people1 = new ArrayList<Object>();
              people1.add(0, "Jose");
              people1.add(1, 500.333333567);
              people1.add(2, Boolean.TRUE);
              people1.add(3, new Date());
              people.add(people1);
              List <Object>people2 = new ArrayList<Object>();
              people2.add(0, "Yes, you!");
              people2.add(1, 100.522222);
              people2.add(2, Boolean.FALSE);
              people2.add(3, new Date());
              people.add(people2);
              List <Object>people3 = new ArrayList<Object>();
              people3.add(0, "Who, me?");
              people3.add(1, 0.00001);
              people3.add(2, Boolean.TRUE);
              people3.add(3, new Date());
              people.add(people3);
              List <Object>people4 = new ArrayList<Object>();
              people4.add(0, "Peter Parker");
              people4.add(1, 11.567444444);
              people4.add(2, Boolean.FALSE);
              people4.add(3, new Date());
              people.add(people4);
              ((SimpleTableModel) simpleTable.getModel()).addAll(people);
          * @param args
          * @throws InvocationTargetException
          * @throws InterruptedException
         public static void main(String[] args) throws InterruptedException, InvocationTargetException {
              final SimpleGui instance = new SimpleGui();
              SwingUtilities.invokeAndWait(new Runnable() {
                   @Override
                   public void run() {
                        instance.constructGui();
              instance.populate();
    }I decided to write a more specific renderer just for that column:
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableCellRenderer;
    * Cell renderer used only by the DividendElement table
    * @author josevnz
    final class HasItCellRenderer extends DefaultTableCellRenderer {
         protected static final long serialVersionUID = 2596173912618784286L;
         private Color hasIt = new Color(255, 225, 0);
         public HasItCellRenderer() {
              super();
              setOpaque(true);
         @Override
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
              Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
              int desCol = table.convertColumnIndexToView(1);
              if (! isSelected && value instanceof Boolean && column == desCol) {
                   if (((Boolean) value).booleanValue()) {
                        comp.setForeground(hasIt);     
                   } else {
                        comp.setForeground(UIManager.getColor("table.foreground"));
              return comp;
          * Override for performance reasons
         @Override
         public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
              // EMPTY
         @Override
         protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
              // EMPTY
         @Override
         public void revalidate() {
              // EMPTY
         @Override
         public void validate() {
              // EMPTY
    } // end classBut the rendering comes all wrong (a String saying true or false, not the expected checkbox from the default renderer) and also there is a weird flickring effect as this particular boolean column is editable (per table model, not show here)...
    I can post the table model and the other renderer if needed (didn't want to put too much code on the question, at least initiallty).
    Should I render a checkbox myself for this cell in the custom renderer? I'm puzzled as I expected the default renderer part of the code to do this for me instead.
    Thanks!
    Edited by: josevnz on Apr 14, 2009 12:35 PM
    Edited by: josevnz on Apr 14, 2009 12:37 PM

    camickr
    Thats because the default render is a JLabel and it just displays the text from the toString() method of the Object in the table model.What I meant to say is that I expected the JCheckbox not a String representation of the boolean value.
    Thats because a different renderer is used depending on the Class of data in the column. Look at the source code for the JTable class to see what the "default >renderer for the Boolean class" is. Then you can extend that or if its a private class then you will need to copy all the code and customize it.At the end I looked at the code and replicated the functionality I needed. I thought than maybe there was a way to avoid replicating the same logic all over again in order to implement this functionality. Good advice, though.
    see you learned nothing from your last posting. This is NOT a SSCCE. 90% of the code you posted is completely irrelevant for the described problem. There is abosutelly no need to post the custom TableModel, because there is no need to use a custom TableModel for this problem. The TableModel has nothing to do with how a column is rendererd.The custom table model returns the type of the column (giving a hint to the renderer on what to expect, right?) and for the one that had a problem it says than the class is Boolean. That's why I mentioned it:
    public Class getColumnClass(int columnIndex) {
        // Code omited....
    You also posted data for 4 columns worth of data. Again, irrelevant. Your question is about a single column containing Boolean data, so forget about the other columns.
    When creating a SSCCE you don't start with your existing code and "remove" code. You start with a brand new class and only add in what is important. That way hopefully if you made a mistake the first time you don't repeat it the second time.That's what I did, is not the real application. I copy & pasted code in a haste from this dummy program on this forum, not the best approach as it gave the wrong impression.
    Learn how to write a proper SSCCE if you want help in the future. Point taken, but there is NO need for you to be rude. Your help is appreciated.
    Regards,
    Jose.

  • How to display result set boolean value as a check box

    Hi guys,
    I am getting the data which include boolean from the database, i need to display the boolean values as check box, see my code, its displaying the data into the table with the boolean values as true and false, how to make it in check boxes
    package swing2.org;
    import java.awt.GridBagLayout;
    import javax.swing.JPanel;
    import java.awt.Color;
    import javax.swing.BorderFactory;
    import javax.swing.border.BevelBorder;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import java.awt.Container;
    import java.awt.GridBagConstraints;
    import java.awt.ComponentOrientation;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    public class Panel2 extends JPanel {
         private static final long serialVersionUID = 1L;
         private JScrollPane jScrollPane = null;
         private JTable jTable = null;
          * This is the default constructor
         public Panel2() {
              super();
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
         //     Panel2.ResultSetFrame();
              GridBagConstraints gridBagConstraints = new GridBagConstraints();
              gridBagConstraints.fill = GridBagConstraints.BOTH;
              gridBagConstraints.gridy = 0;
              gridBagConstraints.weightx = 1.0;
              gridBagConstraints.weighty = 1.0;
              gridBagConstraints.gridx = 0;
              this.setSize(340, 200);
              this.setLayout(new GridBagLayout());
              this.setBackground(new Color(171, 211, 224));
              this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED), null));
              this.add(getJScrollPane(), gridBagConstraints);
          * This method initializes jScrollPane     
          * @return javax.swing.JScrollPane     
         private JScrollPane getJScrollPane() {
              if (jScrollPane == null) {
                   jScrollPane = new JScrollPane();
                   jScrollPane.setViewportView(getJTable());
              return jScrollPane;
          String[] columnNames = {"Task Description",
                 "Time ",
                 "Pop-up",
                 "Sound",
                 "Delete"};
          * This method initializes jTable     
          * @return javax.swing.JTable     
         private JTable getJTable() {
                      ResultSetFrame oo = new ResultSetFrame();
                      JTable table = new JTable(oo.model);
                      table.setBackground(new Color(195, 217, 230));
                      table.setComponentOrientation(ComponentOrientation.UNKNOWN);
                      table.setShowGrid(true);
                      table.setShowVerticalLines(true);
                      table.setRowHeight(17);
                      table.setShowHorizontalLines(true);
                      return table;
    abstract class ResultSetTableModel extends AbstractTableModel
         public ResultSetTableModel(ResultSet aResultSet)
              rs = aResultSet;
          try
               rsmd = rs.getMetaData();     
          catch(SQLException e)
               System.out.println("Error " + e);
       public String getColumnName(int c)
       {  try
          {  return rsmd.getColumnName(c + 1);
          catch(SQLException e)
          {  System.out.println("Error " + e);
             return "";
       public int getColumnCount()
       {  try
          {  return rsmd.getColumnCount();
          catch(SQLException e)
          {  System.out.println("Error " + e);
             return 0;
       protected ResultSet getResultSet()
       {  return rs;
       private ResultSet rs;
       private ResultSetMetaData rsmd;
    class CachingResultSetTableModel extends ResultSetTableModel
    {  public CachingResultSetTableModel(ResultSet aResultSet)
       {  super(aResultSet);
          try
          {  cache = new ArrayList();
             int cols = getColumnCount();
             ResultSet rs = getResultSet();
             /* place all data in an array list of Object[] arrays
                We don't use an Object[][] because we don't know
                how many rows are in the result set
             while (rs.next())
             {  Object[] row = new Object[cols];
                for (int j = 0; j < row.length; j++)
                   row[j] = rs.getObject(j + 1);
                cache.add(row);
          catch(SQLException e)
          {  System.out.println("Error " + e);
       public Object getValueAt(int r, int c)
       {  if (r < cache.size())
             return ((Object[])cache.get(r))[c];
          else
             return null;
       public int getRowCount()
       {  return cache.size();
       private ArrayList cache;
    class ResultSetFrame 
    {  public ResultSetFrame()
          /* find all tables in the database and add them to
             a combo box
          try
          {  Class.forName("com.mysql.jdbc.Driver");
             con = DriverManager.getConnection("jdbc:mysql://localhost:3306/task","root","nbuser");
                stmt = con.prepareStatement("SELECT * FROM tasky");
                   try
                    String query = "SELECT * FROM tasky";
                    rs = stmt.executeQuery(query);
                    model = new CachingResultSetTableModel(rs);
                    JTable table = new JTable(model);
                    scrollPane = new JScrollPane(table);
                catch(SQLException e)
                     System.out.println("Error " + e);
          catch(ClassNotFoundException e)
          {  System.out.println("Error " + e);
          catch(SQLException e)
          {  System.out.println("Error " + e);
       private JScrollPane scrollPane;
       public ResultSetTableModel model;
       private ResultSet rs;
       private Connection con;
       private Statement stmt;
    }

    add a
    public Class getColumnClass(int col) {
         return getValueAt(0, col).getClass();
    }in your ResultSetTableModel which extends AbstractTableModel.
    A simple example
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    import javax.swing.table.AbstractTableModel;
    public class SimpleDemo extends JFrame {
        public SimpleDemo() {
            createAndShowUI();
        private void createAndShowUI(){
            String[] columnName = {"CheckBox Column", "Data Column"};
            Object[][] data = {{new Boolean(true), "Data 1"},
            {new Boolean(false), "Data 2"}, {new Boolean(true), "Data 3"}};
            MyModel model = new MyModel();
            model.setData(columnName, data);
            JTable myTable = new JTable(model);
            JScrollPane scrollPane = new JScrollPane(myTable);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            getContentPane().add(scrollPane);
            pack();
            setLocationRelativeTo(null);
        class MyModel extends AbstractTableModel {
            String[] columnName;
            Object[][] data;
            public void setData(String[] colName, Object[][] theData) {
                this.columnName = colName;
                this.data = theData;
                fireTableStructureChanged();
            public String getColumnName(int column) {
                return columnName[column];
            public Object getValueAt(int rowIndex, int columnIndex) {
                return data[rowIndex][columnIndex];
            public int getRowCount() {
                return data.length;
            public int getColumnCount() {
                return columnName.length;
            public Class getColumnClass(int c) {
                return getValueAt(0, c).getClass();
        public static void main(String[] args){
            Runnable run = new Runnable(){
                public void run(){
                    new SimpleDemo().setVisible(true);
            SwingUtilities.invokeLater(run);
    }

  • Re: Express Query on boolean values

    Hi Simon,
    When the model is run, however, I am able to enter values in the
    other fields and query on them, but I am unable to change the value
    of the checkbox that Express generates for the boolean attribute. If
    the query is run, the data returned is for both true and false values
    of this field.
    Why am I unable to query on this field?The literal answer to your question is: Because Express does not
    support doing queries on Boolean fields.
    The reason is that it is difficult to know how to interpret a
    ToggleField when it comes to search criteria. If "off" means
    find records where this value is FALSE and "on" means find records
    where this value is TRUE, how does one specify to find all records
    regardless of the field value? With DataFields, leaving the field
    blank specifies just this.
    If you want to override this behavior, you'll need to know the
    following:
    Express uses a special widget state to allow users to enter search
    criteria operators (<, >, and so forth) in fields that otherwise
    would not accept these operators (DataFields displaying integers
    or dates). This widget state is called FS_QUERY. What you are
    seeing is that when ToggleFields are in the FS_QUERY state, they
    do not allow the user to change their value.
    The SetWidgetState method is what sets the widget state to FS_QUERY
    when the window enters search mode. So to one step you must take
    to override this behavior is to write a custom SetWidgetState method
    that sets the widget state to FS_UPDATE if the passed widget is a
    toggle field and the passed widget is a ToggleField.
    But this will only allow you to change the state of the ToggleField
    while in Search mode. The next problem is that the window will ignore
    the value of the ToggleField regardless of what it is!
    This time the method of interest is SetSearchConstraint. It looks at
    the widget to get the search constraint. It will only look at DataField
    and ListField widgets, however, and ignore all others. You need to
    create a custom version that looks at the ToggleField and interprets
    the value (look in the Customizing Express applications doc for more
    info on modifying the search criteria).
    Also, the checkbox is highlighted in yellow during the entry of
    search criteria, even though I have set its colour in the window
    workshop customization.
    Where is this colour being set?This is being set in the ExpressWindows.ArrayDesc.SelectRow method.
    This is more difficult to override, as Express is not set up for
    users to override this class with a custom superclass.
    However, you can try setting the ToggleField color in
    DisplayCurrentRecord
    and SetResultSetFromData with code like the following:
    super.DisplayCurrentRecord();
    ArrayWidget.GetField( 1, "MyBooleanFieldName", FALSE ).FillColor =
    C_RED;
    and
    super.SetResultSetFromData();
    ArrayWidget.GetField( 1, "MyBooleanFieldName", FALSE ).FillColor =
    C_RED;
    I haven't tried this, however, and I'm not certain it will work, but
    it's worth a shot. ArrayWidget, in this case, is an attribute of type
    ExpressWindows.ArrayDesc that is defined on
    ExpressWindows.ExpressArrayWindow.
    GetField is defined on this class. Take a peek at it to get a better
    understanding of what it does.
    Good luck!
    Kerry

    Hi Pankaj,
    thank you for the detailed description. I tried to reproduce the issue but in my system I get the results that you are expecting.
    01.04.2010     10.04.2010     91.560,00
    11.04.2010          106.820,00
    Which release, support package level for EA-APPL is implemented in your system?
    Regards, Franz

  • JAXB binding for Boolean

    Hi,
    I'm using xml and JMS to query a remote system.
    One of the values in the remote system that I am interested in is a boolean value. I do not know this field is defaulted in the remote system so I want to use a Boolean object to represent it. I.e I want it to be null is no value is available in the remote system.
    Could any of you give me a quick run down on how to go abount doing this or point me to a tutorial.
    Is there another way of doing what I am trying to do?
    Appreciate any help.
    Cheers,
    Nim

    Hi James,
    Yup, I'm trying to process the xml returned by the remote system.
    The Boolean is an element and not an attribute:
    The schema i am using is shown below:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="accounts" type="AccountsType"/>
    <xsd:complexType name="AccountsType">
    <xsd:sequence>
    <xsd:element name="account" type="Account" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Account">
    <xsd:sequence>
    <xsd:element name="accountId" type="xsd:string"/>
    <xsd:element name="customerId" type="xsd:string"/>
    <xsd:element name="totalAmountOwing" type="xsd:decimal"/>
    <xsd:element name="amountOwing" type="xsd:decimal"/>
    <xsd:element name="totalArrears" type="xsd:decimal"/>
    <xsd:element name="paymentExtensionCount" type="xsd:integer"/>
    <xsd:element name="paymentHistoryIndicator" type="xsd:string"/>
    <xsd:element name="payDate" type="xsd:date"/>
    <xsd:element name="directDebitSchedule" type="xsd:boolean"/>
    <xsd:element name="easyPaySchedule" type="xsd:boolean"/>
    <xsd:element name="billIssueDate" type="xsd:date"/>
    <xsd:element name="arrearsDebtAge" type="xsd:integer"/>
    <xsd:element name="sourceSystemId" type="xsd:string"/>
    <xsd:element name="readFrequency" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    I have access to change the schema. I tried making the boolean an attribute as shown below:
    <xsd:element name="easyPaySchedule">
    <xsd:complexType>
    <xsd:sequence/>
    <xsd:attribute name="value" type="xs:boolean"/>
    </xsd:complexType>
    </xsd:element>
    but I could not see the isSetMethod in the jaxb account implementation file.
    I changed it back and added minOccurs="0":
    <xsd:element name="easyPaySchedule" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
    and started seeing the isSetMethod in the jaxb account implementation class but not the generated account interface.
    Next, I used the xjb file below:
    <jxb:bindings version="1.0"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings schemaLocation="accounts.xsd" node="/xsd:schema">
    <jxb:bindings node="//xsd:complexType[@name='Account']">
    <jxb:bindings node=".//xsd:element[@name='easyPaySchedule']">
    <jxb:property generateIsSetMethod="true"/>
    </jxb:bindings>
    </jxb:bindings> <!-- node="//xsd:complexType[@name='Account'] -->
    </jxb:bindings> <!-- schemaLocation="accounts.xsd" node="/xsd:schema" -->
    </jxb:bindings>
    and I started seeing the isSet methods in the generated Account interface.
    I thought I was in the clear but when I try and run it with the xml below:
    <account>
    <accountId>11111111111</accountId>
    <customerId>2222222</customerId>
    <totalAmountOwing>123</totalAmountOwing>
    <amountOwing>12</amountOwing>
    <totalArrears>0</totalArrears>
    <paymentExtensionCount>1</paymentExtensionCount>
    <paymentHistoryIndicator>110111001111</paymentHistoryIndicator>
    <payDate>2004-10-08+10:00</payDate>
    <directDebitSchedule>false</directDebitSchedule>
    <easyPaySchedule></easyPaySchedule> <<<<<<------ blank instead of false/true
    <billIssueDate>2003-10-08+10:00</billIssueDate>
    <arrearsDebtAge>0</arrearsDebtAge>
    <sourceSystemId>cise</sourceSystemId>
    <readFrequency>Q</readFrequency>
    </account>
    I start to get the following exception:
    javax.xml.bind.UnmarshalException: Unexpected text ""
    - with linked exception:
    [java.lang.NullPointerException]
    Any ideas as to whats going on?
    Cheers,
    Nim

  • Java & Acces: pass boolean values

    Ok I'm totally new at this so the following text will hopefully be understandable. I hope you guys can give me a hand over here.
    The case:
    I'm making a java function that has to create a new user of my database. This user is supposed to get a name, a password and can have 4 functions (Administrator, Author, Reader, Coreader).
    To identify the 4 functions i used a checkbox in my database. So when the box is checked the person is a Admin/author/... Now I was wondering how i can use Java (using a query) to set these values checked or non-checked.
    I thought I'd use booleans, however, my compiler says there is a General Error (all the names of the columns are right, so that's not the deal, my database is working properly and such, ...)
    So here's my code:
    (note that i used these marks ' ' here for the booleans, i tried all kinds of things such as dropping them, using them, ... it doesn't seem the problem...)
    public void addNewUser(String username, String password, boolean admin, boolean author, boolean reader, boolean coreader)
    String query1 = "UPDATE user SET username = '" + username + "' AND password = '"
    + password + "' AND administrator = '" + admin + "' AND author ='" + author
    + "' AND reader ='" + reader + "' AND coreader ='" + coreader + "'";
    try
    stmt = global.createStatement();
    stmt.executeUpdate(query1);
    global.showMessage("The new user, " + username + ", has been added successfuly", "Succesfuly added");
    catch(Exception e)
    global.showError("An error has occured while connecting to the database" + e.toString(), "SQL Error");
    finally
    global.closeConnection();
    Hope you guys can help. Thanks a lot!

    It's possible to do this; it's just that your SQL syntax is completely wrong. An SQL UPDATE statement looks as follows:
    UPDATE table SET column1 = value1, column2 = value2, column3 = value3 WHERE expression
    You're using 'AND' instead of commas, which is the first thing that goes wrong. The second thing that goes wrong is that you're building the SQL statement from bits of string and values. This is a habit that many novice programmers use, and open the door wide for SQL injection attacks. I you do this sort of thing on a web site, you could end up with your customers' credit card details being exposed.
    But because you're just passing the boolean values into the string, they get expanded to a string value, hence TRUE or FALSE. However, because they are string literals, they should be surrounded by single quotes.
    This brings us to the third problem: you're using an UPDATE statement to insert a new record. Use an INSERT statement instead.
    It would be better to use a PreparedStatement. In this case, your code would look as follows:
    PreparedStatement stmt =
        global.prepareStatement( "INSERT INTO user " +
                "( username, password, administrator, author, reader, coreader ) " +
                "VALUES ( ?, ?, ?, ?, ?, ? )" );
        stmt.setString( 1, username );
        stmt.setString( 2, password );
        stmt.setBoolean( 3, admin );
        stmt.setBoolean( 4, author );
        stmt.setBoolean( 5, reader );
        stmt.setBoolean( 6, coreader );I have no idea whether this will work: I don't know Access, and booleans are not a standard feature of SQL. I also don't know whether Microsoft have created their own flavour of SQL, as they are wont to do with any standard.
    All in all, though, you have to really work on your SQL. Three major mistakes in such a simple piece of code means that you don't understand SQL syntax. You may copy and paste this for your assignment, but unless you understand what you're actually doing, you're going to run into trouble again very soon.
    - Peter

  • Why this Error comes "ORA-01461: can bind a LONG value only for insert into

    I'm using Oracle 9.2 with Weblogic 8 server. After Googling i got to resolve this issue "ORA-01461: can bind a LONG value only for insert into a LONG column" by adding : oracle.jdbc.RetainV9LongBindBehavior=true in server properties for the datasource.
    But why did this error come and after keeping the above property why did this error go away ?
    Can anyone help me on this.....

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • ORA- 01461 : Can Bind a long value only for insert into a column error

    I was trying to create a new job using dbms_job.isubmit
    begin
    sys.dbms_job.isubmit(job => 1111,
    what => '',
    next_date => to_date('21-10-2011 03:00:00', 'dd-mm-yyyy hh24:mi:ss'),
    interval => 'TRUNC(SYSDATE+1)+3/24');
    commit;
    end;
    However, I am getting the error 'ORA- 01461 : Can Bind a long value only for insert into a column error'.
    I tried a lot but cant get rid of.
    Any help gurus ?

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • Error ORA-01461: can bind a LONG value only for insert into a LONG column

    Within an existing application , i need to create a new report , i created a new page in it and then tried to create classic report , during wizard when i enter the same query which i have used for previous page , it gives me following error during the creation of report.
    The following bind variable i have already used for previous page. I want to reuse the same bind variables. There is no any long dataype within column predicates.
    Error ORA-01461: can bind a LONG value only for insert into a LONG column
    OK
    Following is the query
    SELECT
       "VWSR_ALL_MERGED_DATA_MV"."SR_AREA" "SR_AREA",
       "VWSR_ALL_MERGED_DATA_MV"."SR_STATUS" "SR_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_SUB_STATUS" "SR_SUB_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_CREATED" "SR_DATE_CREATED",
       "VWSR_ALL_MERGED_DATA_MV"."SR_OPEN_DATE" "SR_OPEN_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CLOSED_DATE" "SR_CLOSED_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT1" "SR_PRODUCT1",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT2" "SR_PRODUCT2",
       "VWSR_ALL_MERGED_DATA_MV"."SR_TIO_PRIORITY" "SR_TIO_PRIORITY",
       "VWSR_ALL_MERGED_DATA_MV"."SR_REF_NUMBER" "SR_REF_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_RECD" "SR_DATE_RECD",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CIDN" "SR_CIDN",
       "VWSR_ALL_MERGED_DATA_MV"."SR_BUS_UNIT" "SR_BUS_UNIT",
       "VWSR_ALL_MERGED_DATA_MV"."SR_NUMBER" "SR_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SOURCE_SYSTEM" "SOURCE_SYSTEM",
       "VWSR_ALL_MERGED_DATA_MV"."BATCH_ID" "BATCH_ID"
    FROM VWSR_ALL_MERGED_DATA_MV
    WHERE trunc(VWSR_ALL_MERGED_DATA_MV.SR_DATE_RECD)=trunc(sysdate-1)
      AND VWSR_ALL_MERGED_DATA_MV.SR_TIO_PRIORITY  IN
                                                    :P2_SR_TIO_PRIORITY
                                                   ,'CEO'
                                                   ,'TER'
                                                   ,'Priority Assistance'
                                                   ,'Enquiry'
      AND   (
            (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                                         'Business Support and Improvement'
                                       , 'Finance and Administration'
                                       , 'Cust Sat Simplification and Productivity'
                                       , 'Project New and Customer Experience'
                                       , 'Corp Strategy and Customer Experience'
                                       , 'Other'
                AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('BS&I'))
       OR   (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                                         'Consumer'
                                       , 'Consumer Telstra Country Wide'
                                       , 'Customer Service and Sales'
                                       , 'Offshore Sales and Service'
                                       , 'TC and TCW Operations'
                                       , 'Telstra Country Wide'
                                       , 'Other'
                AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('TC&C'))
       OR   (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                             'Telstra Customer Sales and Service'                  
                            ,'Telstra Program Office'
                            ,'Human Resources'
                            ,'IT'
                            ,'Unallocated'
                            ,'Other'
                AND :P2_SR_BUSINESS_UNIT= 'OTHER')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                        'Telstra Operations'
                       ,'Telstra Networks and Services'
                       ,'Other'
                AND :P2_SR_BUSINESS_UNIT= 'TO')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Business'
                AND :P2_SR_BUSINESS_UNIT= 'TB')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Wholesale'
                AND :P2_SR_BUSINESS_UNIT= 'TW')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Enterprise and Government'
                AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('TE&G'))
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Sensis'
                     ,'Sensis Pty Ltd'
                AND :P2_SR_BUSINESS_UNIT= 'SENSIS')
    AND :P2_SR_TIO_PRIORITY = 'Level 0'
    UNION
    SELECT
       "VWSR_ALL_MERGED_DATA_MV"."SR_AREA" "SR_AREA",
       "VWSR_ALL_MERGED_DATA_MV"."SR_STATUS" "SR_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_SUB_STATUS" "SR_SUB_STATUS",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_CREATED" "SR_DATE_CREATED",
       "VWSR_ALL_MERGED_DATA_MV"."SR_OPEN_DATE" "SR_OPEN_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CLOSED_DATE" "SR_CLOSED_DATE",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT1" "SR_PRODUCT1",
       "VWSR_ALL_MERGED_DATA_MV"."SR_PRODUCT2" "SR_PRODUCT2",
       "VWSR_ALL_MERGED_DATA_MV"."SR_TIO_PRIORITY" "SR_TIO_PRIORITY",
       "VWSR_ALL_MERGED_DATA_MV"."SR_REF_NUMBER" "SR_REF_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SR_DATE_RECD" "SR_DATE_RECD",
       "VWSR_ALL_MERGED_DATA_MV"."SR_CIDN" "SR_CIDN",
       "VWSR_ALL_MERGED_DATA_MV"."SR_BUS_UNIT" "SR_BUS_UNIT",
       "VWSR_ALL_MERGED_DATA_MV"."SR_NUMBER" "SR_NUMBER",
       "VWSR_ALL_MERGED_DATA_MV"."SOURCE_SYSTEM" "SOURCE_SYSTEM",
       "VWSR_ALL_MERGED_DATA_MV"."BATCH_ID" "BATCH_ID"
    FROM
       VWSR_ALL_MERGED_DATA_MV
    WHERE trunc(VWSR_ALL_MERGED_DATA_MV.SR_DATE_RECD)=trunc(sysdate-1)
       and VWSR_ALL_MERGED_DATA_MV.SR_TIO_PRIORITY IN (:P2_SR_TIO_PRIORITY)
    AND  (
         (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN (
                         'Business Support and Improvement'
                       , 'Finance and Administration'
                       , 'Cust Sat Simplification and Productivity'
                       , 'Project New and Customer Experience'
                       , 'Corp Strategy and Customer Experience'
                       , 'Other'
    AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('BS&I'))
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN (
                         'Consumer'
                       , 'Consumer Telstra Country Wide'
                       , 'Customer Service and Sales'
                       , 'Offshore Sales and Service'
                       , 'TC and TCW Operations'
                       , 'Telstra Country Wide'
                       , 'Other')
    AND  :P2_SR_BUSINESS_UNIT= htf.escape_sc('TC&C'))
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                             'Telstra Customer Sales and Service'                  
                            ,'Telstra Program Office'
                            ,'Human Resources'
                            ,'IT'
                            ,'Unallocated'
                            ,'Other'
            AND :P2_SR_BUSINESS_UNIT= 'OTHER')
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                          'Telstra Operations'
                          ,'Telstra Networks and Services'
                          ,'Other'
            AND :P2_SR_BUSINESS_UNIT= 'TO')
    OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                         'Telstra Business'
            AND :P2_SR_BUSINESS_UNIT= 'TB')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Wholesale'
            AND :P2_SR_BUSINESS_UNIT= 'TW')
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Telstra Enterprise and Government'
            AND :P2_SR_BUSINESS_UNIT= htf.escape_sc('TE&G'))
       OR (VWSR_ALL_MERGED_DATA_MV.SR_BUS_UNIT IN
                      'Sensis'
                     ,'Sensis Pty Ltd'
            AND :P2_SR_BUSINESS_UNIT= 'SENSIS')
    AND :P2_SR_TIO_PRIORITY = 'Level 1'Edited by: user13653962 on 30/01/2013 15:11
    Edited by: user13653962 on 30/01/2013 15:14

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • How to get the value from the checkbox

    Hi All,
    Good Evening,
    i want to get the value from the check box.
    for this i wrote like this
    OAMessageCheckBoxBean cbb=(OAMessageCheckBoxBean)webBEan.findChildRecurssive("item240")
    String val=cbb.getvalue(pageContext).toString();
    val getting the value only when checkbox is checked.
    suppose check box is not checked that time i got NULL POINTER exceptionn.
    so
    i tried the following way alsoo
    string val=pageContext.getParameter("item240");
    here val return 'on' only when checkbox is checked.
    otherwise NULL value returnss.
    but i want to get the value is 'Y' when i am checked the checkbox
    otherwise returns NULL valuee.
    already i set the checkbox properties alsoo
    Checked :Y
    unchecked:N
    pls tell me

    Hi,
    use
    try
    OAMessageCheckBoxBean cbb=(OAMessageCheckBoxBean)webBEan.findChildRecurssive("item240")
    String test = cbb.getvalue(pageContext).toString();
    catch(Exception e)
    String test = "";
    this way you can handle null pointer exception.
    Thanks,
    Gaurav

  • Getting values from a checkbox

    I am iterating through a vector and displaying the values in checkbox format. The problem I have is that my servlet can only see one value that has been selected from the checkbox.
    The JSP code is as such:
    <%int checkBoxIndex = 0;
    Vector abc = (Vector)session.getAttribute("vector");
    Enumeration e = abc.elements()
    while(e.hasMoreElements())
    code........
    checkBoxIndex ++;
    %>
    <input type=checkbox name="Select" value="<%= checkBoxIndex%>">
    <%}%>
    In the servlet, I am getting the selected values as such:
    String screenInput[] = request.getParameterValues("Select");
    Please help me with ideas of how to get all the selected values from the checkbox.

    Please send the full code, its not proper, i dont understand whether the checkbox is displayed only once or multiple times.

  • How to use Boolean values from 2 different sources to stop a while loop?

    I am working on a program for homework that states E5.4) Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. Be sure to include the Time Delay Exress Vi so the user has time to press the stop botton. 
    I am doing this right now but it seems as though I can only connect one thing to the stop sign on th while loop. It won't let me connect a comparision of N and the iterations as well as the stop button to the stop sign on the while loop. So how would I be able to structure it so that it stops if it receives a true Boolean value from either of the 2 sources (whichever comes first)? 
    Basically, I cannot wire the output of the comparison of N and iterations as well as the stop button to the stop button on the whlie loop to end it. Is there a solution?
    Thanks!
    Solved!
    Go to Solution.

    Rajster16 wrote:
    Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. 
    Look in the boolean palette for something similar to the word hightlighted in red above.
    LabVIEW Champion . Do more with less code and in less time .

  • Error - '' is not a valid boolean value

    I have been receiving the error message = '' is not a valid Boolean value quite frequently.  It doesn’t matter which hierarchy I am in but it’s typically when I do an Add or Insert.  When selecting ‘ok’ on the error message, I’m able to continue on with my work but was just curious what causes this error.  Sometimes when this error shows up and I click ‘ok’, it will take me out of the DRM screen and into whatever else I may have open at the moment.  Any thoughts or ideas?  We are on version 11.1.1.2.103

    As Murali stated-
    It could be a property incorrectly configured, check all the boolean type properties and see if any of them are getting a string value by any chance.
    Thanks
    Denzz

Maybe you are looking for