0

I've been looking at this all the morning and I am starting to get desperate.

I have datatable and inside it var="message".

<h:dataTable value="#{usuarioMBean.usuario.recibidos}" var="message" id="messages" >

Message is a class that contains member recibe

private Usuario recibe;

I know the datatable works correctly and that the message is being set because when I try to use it without if, when or choose statements, it works.

One of my messages is null, however, when I try to check whether it is null, it doesn't work.

<h:outputText rendered="#{empty message.recibe}" value="text"  />

<c:choose>
    <c:when test="${empty message.recibe}">
      Queja
    </c:when>
    <c:otherwise>
      #{message.recibe.nombre} #{message.recibe.apellidos}
    </c:otherwise>
</c:choose

Concretely, the h:outputText is never shown, neither is Nombre and Apellidos. However, Queja is shown always.

What I am trying to do is simply write "Queja" when the recibe is null.

Thanks.

Samuel
  • 2,430
  • 5
  • 31
  • 41
  • Seems like `message#recibe` always have a value. What's the scope of your `message` bean? – Luiggi Mendoza May 02 '14 at 16:24
  • It is not a bean, it is a variable defined in a databale – Samuel May 02 '14 at 16:28
  • And I create the messages manually so it is null for sure :-/ – Samuel May 02 '14 at 16:29
  • Then I completely don't understand. If you already know `message.recibe` won't be `null`, why would you want to show anything if this variable is `null`? – Luiggi Mendoza May 02 '14 at 16:31
  • No no no :). It is null one of 3 times. And when it is, I want to write Queja. – Samuel May 02 '14 at 16:32
  • Ok, then edit your current question and provide the related code. Otherwise, it is impossible to understand your problem. – Luiggi Mendoza May 02 '14 at 16:32
  • Buw what do you not understand? It is the last sentence - What I am trying to do is simply write "Queja" when the recibe is null. – Samuel May 02 '14 at 16:36
  • I don't understand how you're creating/filling `message.recibe` in your datatable. Because if what you state is true, then this should work as expected. So, I need to check how you're filling the data to understand where is your real problem. – Luiggi Mendoza May 02 '14 at 16:37
  • I don't create anything. Datatable iterates over all messages and the current message puts into "message". "message" is of class Message that has member recibe. The recibe is sometimes null and I want to replace it when it is. – Samuel May 02 '14 at 16:40
  • And that's what I want to check in your code, **not from your words**. – Luiggi Mendoza May 02 '14 at 16:41
  • 2
    Yes, it is. I don't really understand why do you have this problem, looks like it should be fine. Anyway, check on this: [JSTL in JSF2 Facelets… makes sense?](http://stackoverflow.com/q/3342984/1065197). – Luiggi Mendoza May 02 '14 at 17:02
  • Wow, this was exactly the problem, thank you very much! I didn't know there is a such a thing as build and render time. If you rewrite your comment as an answer, I will accept it as solution. – Samuel May 04 '14 at 19:46

0 Answers0