Check the documentation for the tag

http://struts.apache.org/2.0.14/docs/select.html

I was referring to the attribute  'name', which indicates the name used to
get the select value from the Action, and also to send the value back to the
server. It should be something like this

<s:select
               headerKey='-1' headerValue='--Select--'
               list='dtList'
               listKey='objid'
               listValue='description'
               name='listbean.domainType' onchange='function1(this)'
                />.

With respect to the id, it's something outside this forum, but what you have
is basically this:
      boolean output=false;
      int result = 0;
      try {
        [...]
          if (listbean.getObjid()!=null){
            [do the update]
          }

          else{

              System.out.println("In ");
              String query= "INSERT INTO DOMAIN
(OBJECTID,ISACTIVE,CODE,DESCRIPTION,ISEDITABLE,DOMAINTYPE_OID) VALUES
(?,?,?,?,?,?)" ;
              stmt = con.prepareStatement(query);
              // Now you increment result, which was created with value 0,
and therefore after the increase will always be 1
              stmt.setInt(1,++result);
              // This trace does not make any sense at all. The objid,
whicheve value it has, it's completely lost.
              System.out.println("OBJECTID"+ listbean.getObjid());
              stmt.setBoolean(2, (listbean.getActive()));
              stmt.setString(3, listbean.getCode());
              stmt.setString(4, listbean.getDescription());
              stmt.setBoolean(5, (listbean.getEdit()));
              stmt.setInt(6,listbean.getDt_oid());
              stmt.executeUpdate();
              output= true;
          }

        }



2011/3/16 JavaNoobie87 <vivek...@enzentech.com>

>
> JOSE L MARTINEZ-AVIAL wrote:
> >
> > Well, the NPE is due to the fact that you are setting declaring dt_oid as
> > an
> > Integer(which can be null) but in the method listdomain is an int. The
> JVM
> > automatically tries to convert Integer to int, but if it's null, it will
> > throw a NPE, since an int can not be null. That's the first thing you
> > should
> > look at. Also, who and when is setting dt_oid? Because there is no such
> > field in the jsp, so it will always be empty. And you will always get
> that
> > exception.
> >
> > Second, if you want to fill the domaintype in the bean, as the rest of
> > fields, you will need to rename the select to listbean.domainType, as the
> > rest of fields in the form. Otherwise it will not be loaded in the bean.
> > Also, you should revise the logic used to create the ids in the DAO. As
> it
> > stands, the objectid will always be 1.
> >
> > Third, IMO your code is hard to read. If you create an object of class
> > DomainBean, do not call it listbean, because everybody that reads it will
> > be
> > puzzle why something that is not a list is called list.
> >
> >
> Well, first off I  sincerely apologize for using an improper naming
> technique I'm totally new to coding in itself  :s. As Suggested ,Ive
> changed
> the return value of  dt_oid  and objid across the code . And im trying to
> set it through the jsp  by modifying the select tag .
> as below.
> &lt;s:select
>                headerKey=&quot;-1&quot; headerValue=&quot;--Select--&quot;
>                list=&quot;dtList&quot;
>                listValue=&quot;listbean.code&quot;
>                listValue=&quot;listbean.dt_oid&quot;
>                name=&quot;listbean.domainType&quot;
> onchange=&quot;function1(this)&quot;
>                 /&gt;.
> I'm not sure how far this is effective though as the drop down form the jsp
> is empty . Even though the source shows the various options.
> Also I dont understand what you mean by creating the ids,could you please
> explain?
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3766102.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to