webtier@glassfish.java.net

Re: composite component with "for" attribute in jsf2.0 - is it possible?

From: <webtier_at_javadesktop.org>
Date: Thu, 01 Apr 2010 08:17:46 PDT

I updated the EL to 2.2 and your code works, but there is still something unclear to me.
I'm interested not in the message list belonging to a clientId but I would like to know if there is at least one message for that client id.

I tryed with:

<span id="#{cc.clientId}">
        <c:if test="#{facesContext.getMessageList(cc.attrs.for).size != 0}">
                <h:outputText value="here we are"/>
        </c:if>
</span>

but I got this error

javax.faces.view.facelets.TagAttributeException: /resources/mtc/message1.xhtml @17,70 test="#{facesContext.getMessageList(cc.attrs.for).size != 0}" For input string: "size"
        at com.sun.faces.facelets.tag.TagAttributeImpl.getObject(TagAttributeImpl.java:324)
        at com.sun.faces.facelets.tag.TagAttributeImpl.getBoolean(TagAttributeImpl.java:129)
        at com.sun.faces.facelets.tag.jstl.core.IfHandler.apply(IfHandler.java:85)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
        at com.sun.faces.facelets.tag.composite.ImplementationHandler.apply(ImplementationHandler.java
..............

Caused by: java.lang.NumberFormatException: For input string: "size"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
........

I used also
<c:if test="#{facesContext.getMessageList(cc.attrs.for).size() != 0}">

but it doesn't work either. why?

I tried then using a bean with a function like this:
public boolean areThereAlarms(String clientId){
                boolean retval = false;
                // See if there are messages queued for the page
        Severity severityLevel = getFacesContext().getMaximumSeverity();

        if (null != severityLevel) {
                List list = getFacesContext().getMessageList(clientId);
                System.out.println("clientid = "+clientId + " "+list.size());
                if(list != null){
                        if(! list.isEmpty()){
                                System.out.println("list ok");
                                retval = true;
                        }
                }

        }
        return retval;
        }

and

<span id="#{cc.clientId}">
  <h:outputText value="here we are" rendered="#{alertBean.areThereAlarms(cc.attrs.for)}">
</span>

but the list is always empty because there is no match with the clientId. It works only if I use the complete name of the clientId ("j_idt10:j_idt85:j_idt86:j_idt87:"+clientId).
I don't undestand why.
In any case how can I get the complete id of the client from cc.attrs.for ? Is there any API I can use within the bean?
[Message sent by forum member 'maxqua72']

http://forums.java.net/jive/thread.jspa?messageID=394912