Robert, you are absolutely right. I am trying to build a personal message inbox using Struts. I use the word "Thread" to represent a discussion topic. My ThreadHandler is a business tier class. The word Thread has nothing to do with the java.lang.Thread.
-Caroline --- Robert Taylor <[EMAIL PROTECTED]> wrote: > I don't think ThreadHandler represents a > java.lang.Thread handler. > I think it more or less is a business object to > facilitate persistance. > I think the use of the word "Thread" here is more > representative of a > forum discussion thread. > > I could be wrong though. > > robert > > > > -----Original Message----- > > From: Yee, Richard K,,DMDCWEST > [mailto:[EMAIL PROTECTED] > > Sent: Thursday, January 08, 2004 12:00 PM > > To: 'Struts Users Mailing List' > > Subject: RE: All The Bean Properties Are Null in > the Business Tier!!! > > (Used BeanUtils to Convert DynaValidatorForm) > > > > > > Caroline, > > May I ask why you are performing your database > updates through a separate > > thread? It seems to be complicating your code. > Creating lots of > > threads from > > within your web application is not a good practice > if you want your app to > > scale well. Also, what happens if the update > doesn't succeed? You have no > > way of notifying the user. > > > > The code: > > <snip> > > ThreadBean threadBean = new ThreadBean(); > > > > String receiver = threadBean.getReceiver(); > > String sender = threadBean.getSender(); > > </snip> > > > > is your problem unless your ThreadBean constructor > can populate itself > > correctly with the desired values. > > If you must use threads, then you should be able > to create a > > ThreadHandler, > > call a setter method on it and set you ThreadBean > instance variable, and > > then call the run method on the ThreadHandler to > start the thread. > > > > Regards, > > > > Richard > > > > -----Original Message----- > > From: Caroline Jen [mailto:[EMAIL PROTECTED] > > Sent: Thursday, January 08, 2004 8:48 AM > > To: Struts Users Mailing List > > Subject: RE: All The Bean Properties Are Null in > the Business > > Tier!!! (Used > > BeanUtils to Convert DynaValidatorForm) > > > > > > Thank you for your comment, which is very helpful. > > > > Instead of extends ThreadBean, I now import the > > ThreadBean into my ThreadHandler class (see the > code > > below). I am still getting all null or zero values > > from the bean. > > > > What is the proper way to do it? I simply want to > > insert the value of all the properties into the > > database. Most of the fields in my database > require > > NOT NULL. > > > > code: > > ================================================== > > import org.apache.artimus.message.ThreadBean; > > > > class ThreadHandler > > { > > ThreadBean threadBean = new ThreadBean(); > > > > String receiver = threadBean.getReceiver(); > > String sender = threadBean.getSender(); > > String threadTopic = threadBean.getPostTopic(); > > String threadBody = threadBean.getPostBody(); > > Timestamp threadCreationDate = > threadBean.getThreadCreationDate(); > > int threadViewCount = > > threadBean.getThreadViewCount(); > > int threadReplyCount = > > threadBean.getThreadReplyCount(); > > > > MessageDAO md = new MySQLMessageDAO(); > > public int insertThread( ThreadBean threadBean > ) > > throws > MessageDAOSysException, > > > > > ObjectNotFoundException > > > > { > > System.out.println( "The sender is " + > sender + > > "." ); > > System.out.println( "The subject is " + > > threadTopic + "." ); > > System.out.println( "The creation date is " > + threadCreationDate ); > > System.out.println( "The number of replies > are " > > + threadReplyCount ); > > > > md.createThread( receiver, sender, > threadTopic, > > threadBody, > threadCreationDate, > > > > threadViewCount, > > threadReplyCount ); > > > > int threadID = 0; > > ..... > > ..... > > return threadID; > > } > > } > > > > > > --- Robert Taylor <[EMAIL PROTECTED]> wrote: > > > Your code seems a bit confusing based upon what > you > > > want to > > > achieve. > > > > > > If indeed you want ThreadHandler to inherit from > > > ThreadBean, > > > you should be able to do something like this: > > > > > > DynaActionForm postForm = ( DynaActionForm > )form; ThreadHander = new > > > ThreadHandler(); BeanUtils.copyProperties( > threadHandler, postForm ); > > > > > > threadHandler.insertThread(); > > > > > > > > > The reason you are getting null and zero values > in ThreadHandler > > > is that you are populating a new instance of > > > ThreadBean here: > > > > > > > > > DynaActionForm postForm = ( DynaActionForm > > > )form; > > > > > > ThreadBean threadBean = new ThreadBean(); > > > > > > BeanUtils.copyProperties( threadBean, > postForm > > > ); > > > > > > ... and then you get a new instance of > ThreadHandler > > > here: > > > > > > > > > ThreadHandler thandler = new > ThreadHandler(); > > > > > > At this point, ThreadHandler knows nothing of > your > > > populated > > > instance of ThreadBean. Instead it is getting > values > > > from > > > its own "empty" ThreadBean parent here: > > > > > > > class ThreadHandler extends ThreadBean > > > > { > > > > String receiver = getReceiver(); > > > > String sender = getSender(); > > > > String threadTopic = getPostTopic(); > > > > String threadBody = getPostBody(); > > > > Timestamp threadCreationDate = > > > > getThreadCreationDate(); > > > > int threadViewCount = getThreadViewCount(); > > > > int threadReplyCount = > getThreadReplyCount(); > > > > > > > > ..... > > > > ..... > > > > } > > > > > > > > > ...unless you do something like the following in > === message truncated === __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

