Hi Simon,
thank you for the clue. Makeing the change to the appointment constructor
resolved this issue.
Regards
Ayub
On Thu, Oct 30, 2008 at 5:26 PM, Ayub Khan <[EMAIL PROTECTED]> wrote:
> Hi Simon,
>
> Thank you for the detailed clarification.
>
> I add the below constructor to Appointment bean so that the commentItemMap
> is initialiased.
>
>
> *public* HaAppointment() {
>
> CommentItem item=
> *new* CommentItem();
>
> commentItemMap.put("Cancellation Reason", item);
>
> }
>
>
>
> Still I am getting the following error :
> com.sun.faces.lifecycle.ProcessValidationsPhase execute Error testing
> property 'commenttext' in bean of type null
>
> *javax.faces.el.PropertyNotFoundException*: Error testing property
> 'commenttext' in bean of type null
>
> Can you suggest an option to resolve this issue ?
>
> Regards
>
> Ayub
>
> On Thu, Oct 30, 2008 at 4:59 PM, Simon Kitching <[EMAIL PROTECTED]>wrote:
>
>> Ayub Khan schrieb:
>> > Hi,
>> >
>> > I am having a small issue, I am getting
>> >
>> > Error testing property 'commenttext' in bean of type null error
>> > message. I googled and did lot of troubleshooting, however unable to
>> > resolve it.
>> >
>> > I have a managed bean AppointmentBean which has a Map of comments
>> >
>> > Appointment{
>> >
>> > private Map commentitemMap=new HashMap();
>> >
>> > *
>> >
>> > public
>> >
>> > * Map getCommentItemMap() { *return* *this*.commentItemMap;
>> >
>> > }
>> >
>> > *public* *void* setCommentItemMap(Map commentItemMap) {
>> > *this*.commentItemMap = commentItemMap;
>> >
>> > }
>> >
>> > }
>> >
>> > in my jsp I have bound the text area to
>> > appointment.commentItemMap['Cancellation Reason'].commenttext
>> >
>> > CommentItem {
>> >
>> > *private* String commenttext="";*
>> >
>> > public
>> >
>> > * String getCommenttext() { *return* *this*.commenttext;
>> >
>> > }
>> >
>> > *public* *void* setCommenttext(String commenttext) {
>> > *this*.commenttext = commenttext;
>> >
>> > }
>> >
>> > }
>> >
>> >
>> >
>> > In my action method I am setting the commentItem value as below:
>> >
>> > CommentItem item=
>> >
>> > *new* CommentItem();
>> >
>> > comentMap.put(
>> >
>> > "Cancellation Reason",item);
>> >
>> > appointment.setCommentItemMap(comentMap);
>> >
>> >
>> >
>> > when the form is submitted, I read
>> >
>> > Error testing property 'commenttext' in bean of type null error message.
>> >
>> > In the facesConfig.xml I have declared both appointments bean and
>> > CommentItem as managed beans in session scope.
>> >
>> > If I use appointment.commentItemMap['Cancellation Reason'] without the
>> > .commenttext , the full classpath of CommentItem is being displayed in
>> > the text area (I assume its the object.toString value here ).
>> >
>> > Please let me know where I am doing wrong.
>> >
>> When the form is submitted, the posted form-content will include a value
>> for the "commenttext" html field (this value will be an empty string if
>> you typed nothing in that field in the html page). During the "update
>> model" phase, JSF will therefore try to store that value using the EL
>> expression
>> #{appointment.commentItemMap['Cancellation Reason'].commenttext}
>> so it
>> (a) fetches the appointment bean (ok)
>> (b) calls getCommentItemMap --> returns an *empty* map
>> (c) calls map.get('Cancellation Reason') --> returns null
>> (d) tries to call getCommenttext on the null pointer --> error
>>
>> Only *after* the model-update phase will it try to run the "action"
>> method associated with whatever button was pressed. So it is too late at
>> that point to try to add an object to your commentItemMap with key
>> 'Cancellation Reason'; processing has already tried to access the
>> nonexistent object earlier.
>>
>> Regards,
>> Simon
>>
>> --
>> -- Emails in "mixed" posting style will be ignored
>> -- (http://en.wikipedia.org/wiki/Posting_style)
>>
>>
>
>
> --
> -- "Two roads diverged in a wood
> And I took the one less traveled by
> And that has made all the difference.
>
> Robert Frost....."
>
--
-- "Two roads diverged in a wood
And I took the one less traveled by
And that has made all the difference.
Robert Frost....."