struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rokibul Islam Khan <krisla...@gmail.com>
Subject Re: Can't not reference to property of object which is property of Bean
Date Wed, 01 Jun 2005 05:52:13 GMT
hi,
U r getting that because of null property of privateMessage. As u r
using nested bean i.e. privateMessage.subject will be interpreted as
formBean.getPrivateMessage.getSubject() where as getPrivateMessage()
is returning null in ur case which cause Null pointer exception. To
avoid this u have two option. first u can make an object explicityly
from action and set it to formbean everytime before the call to the
page by setPrivateMessage() or initialize the privateMessage from the
constructor of ur form bean and overriden reset method. Remember u
have to override reset method and initialize privateMessage again if u
follow second option.



On 6/1/05, Pham Anh Tuan <anhtuan@ichi-corp.jp> wrote:
> Hi all,
> 
> I have 1 problem:
> 
> I tried to do something like below:
> 
> test.jsp includes:
> <html:form action="/user/sendPrivateQuestion.do" styleId="userBean">
> 
>     <html:text property="privateMessage.subject" name="userBean"/>
> 
> </html:form>
> 
> I've already defined privateMessage in my userBean like below:
> 
>     /**
>      * Comment for <code>privateMessage</code>
>      * This property is Private Message object
>      */
>     private PrivateMessage privateMessage = null;
> 
>     /**
>      * TODO: This will get value of privateMessage
>      *
>      * @return PrivateMessage the privateMessage.
>      */
>     public PrivateMessage getPrivateMessage() {
>         return privateMessage;
>     }
>     /**
>      * TODO: This will set value to privateMessage
>      *
>      * @param PrivateMessage The privateMessage to set.
>      */
>     public void setPrivateMessage(PrivateMessage privateMessage) {
>         this.privateMessage = privateMessage;
>     }
> 
> But when I action mapping to test.jsp page, I have errors with message :
> 
> org.apache.jasper.JasperException: Null property value for 'privateMessage'
> 
> Plz, help me!
> 
> Thanks for ur reading
> 
> Anh Tuan
> 
> 


-- 
--
Rokibul Islam Khan
=================
Software Programmer
Spectrum Engineering Consortium Ltd.
Chandrashila Shuvastu Tower
Panth Path, Dhaka

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message