myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "PÉNET LUDOVIC" <l.pe...@senat.fr>
Subject Problem with tag component
Date Thu, 01 Nov 2012 09:31:26 GMT
Hi.

I have a problem with a tag component.
It behaves ok, excepted that I can not retrieve updated bean value in a
backend bean using evaluateExpressionGet or similar method. I always get
the original one.

My tag file looks like :

?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib id="sentest"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
    version="2.0"
>
    <namespace>http://www.senat.fr/taglib/sentest</namespace>

[...]
    <tag>
        <description>
            <![CDATA[
            À COMPLÉTER
            ]]>
        </description>
        <tag-name>senMandats</tag-name>
    <source>tags/sen/senMandats.xhtml</source>
        <attribute>
            <description>
                <![CDATA[
        Identifiant unique.
        ]]>
            </description>
            <name>id</name>
            <required>true</required>
            <type>java.lang.String</type>
        </attribute>
        <attribute>
            <description>
                <![CDATA[
     Contexte de sélection du Sénateur.
    ]]>
            </description>
            <name>context</name>
            <required>true</required>
        </attribute>
    </tag>
</facelet-taglib>

The component is defined using ui:composition. It looks like (nothing
special) :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="fr"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:p="http://primefaces.org/ui"
    xmlns:sen="http://java.sun.com/jsf/composite/sen"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:sf="http://www.senat.fr/taglib/senfunctions"
    xmlns:st="http://www.senat.fr/taglib/sentest"
    xmlns:o="http://omnifaces.org/ui"
    xmlns:of="http://omnifaces.org/functions">
    <h:head/>
    <h:body>
        <ui:composition>
    [...]
        </ui:composition>
    </h:body>
</html>

I am passing dynamic el values to those custom components.

Example :

<st:senMandats id="toto" context="#{selectionContext}"/>

The selectionContext bean being defined elsewhere.

In st:senMandats, I use other custom components in a nested way. Something
like :

<st:listeMandats mandatContext="#{sensContext}"
asen="#{selectionContext.selectedSen}"/>

The listeMandat component uses a primefaces dataTable to display some
lists from the context. So, I have code like :

<h:outputLabel value="listeMandats de #{asen.libelleLong}"
styleClass="bigTitleMandats" rendered="#{not empty asen}" />
<p:dataTable id="tableMandatsSenatoriaux" value="#{mandatContext.asList}"
/* lots of other parameters */>

When I select an entry in the picker, the custom component gets properly
updated (an update is triggered by the picker). I can see that the
valueDisplayed by the h:outputLabel is correctly updated depending on the
selection.

When #{mandatContext.AsList} is called, I am retrieving #{asen} from the
application context and performing some internal update before returning
the requested list. There comes the problem : if #{asen} seems to be ok
when rendering #{asen.libelleLong}, I can not get the updated value from
the backing bean.

I am using the following function :

@SuppressWarnings("unchecked")
public static <T> T findBean(String name) {
    if ((name == null) || name.isEmpty())
        return null;
    FacesContext fc = FacesContext.getCurrentInstance();
    logger.debug("Retrieving #{" + name + "}");
    return (T) fc.getApplication().evaluateExpressionGet(fc,
            "#{" + name + "}", Object.class);
}

in the AsList method :

JSFUtils.findBean("asen")

It always return an old, not updated value.

What should I do so that my bean can access the updated value ? I tried
the solutions 4, 5 and 6 proposed by mykong in
http://www.mkyong.com/jsf2/access-a-managed-bean-from-event-listener-jsf/
but still does not get the right value.

Am I forced to code a custom component class, deriving from a specific
class ? If so, am I forced to also code a renderer ? I would like to avoid
that, as I appreciate to have the layout in an xhtml file.

Thanks in advance.

I am using :

PrimeFaces 3.4.1
CODI 1.0.5
OpenWebBeans 1.1.6
MyFaces 2.1.9
Tomcat 7.0.32

I asked this question on stackoverflow :
http://stackoverflow.com/questions/13163033/getting-dynamic-parameters-of-a-jsf-2-custom-component-from-a-backing-bean

@BalusC suspected "a bug in the JSF impl used as to referencing EL
expressions in tag file attributes" and I will try with Mojarra on monday
(bank holiday here in France).

What is your opinion ?

Thanks in advance,

Ludovic

|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|


Mime
View raw message