• Post Reply Bookmark Topic Watch Topic
  • New Topic

Condition check in using rendered

 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have basic question.

I am displaying all the values of output. I am using the below tag to display date. Whenever the date is null, it is throwing null pointer exception. I tried to use rendered to fix this. But didn't work out. Please correct my code and help me.

<hutputText id="begindate" value="#{beanInstance.beginDate}" rendered="#{! empty beanInstance.beginDate}">
<f:convertDateTime pattern="MM/dd/yyyy"/>
</hutputText>

When i change rendered ="#{false}". Its working. whenever database value for beginDate is not null it is working.

Thanks
Pardha
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try 'rendered="#{! (empty beanInstance.beginDate)}"'.
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Luck. Same result -- Null pointer exception whenever beanInstance.beginDate is null from DB.

Thanks
Pardha
 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone reply for my earlier post.

Thanks
Pardha
 
Jagadeeswara Yaramala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

1) rendered="#{!(beanInstance.beginDate==null)}"

or

2) rendered="#{!(beanInstance.beginDate=='null')}" /* This is because null is a reserved literal in Java */

I think you should check for null which is for reference variables like Date.

 
Pardha Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both the options not working.

Thanks
Pardha
 
Liangfeng Ren
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, probably need you to provide the error log to see where the nullpointexception was thrown from.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!