FacesComponent works on one page, but not on others (extracts null from ajax event)

I do not know if there is a resolved question for this. If so, I could not find him.

I am creating a composite component with two SelectOneMenu that fire an event. The fact is that this component works in one jsf, but not in others.

The component is inside three different xhtml. In all of them, the event fires when I change the value of the first SelectOneMenu, but only in one of the xhtml is the value of SelectItem not null. In the rest of them, the resulting value is "null"

 //In p001DatosNotificacion.xhtml, it retrieves the selected value of the selectonemenu (b, for example)
 //In the others it retrieves null

 UISelectOne oneVoewl = (UISelectOne)event.getSource();
 System.out.println("One Voewl > " + oneVoewl.getValue());

Can someone help me and tell me where I am making a mistake?

Thanks in advance!

The code

Bean component support

@FacesComponent(value="letterExample")
public class LetterExample extends UINamingContainer{

    public void voewlAjaxListener(AjaxBehaviorEvent event){
        UISelectOne oneVoewl = (UISelectOne)event.getSource();
        System.out.println("One Voewl > " + oneVoewl.getValue());

    }

Composite component (Note: I am using an existing bean for testing)

<cc:interface componentType="letterExample" >
    <cc:attribute name="bean" type="es.ccasa.sgnx.business.bean.Direccion" />
</cc:interface>


<cc:implementation>

    <p:selectOneMenu id="oneMenuVoewl" value="#{cc.attrs.bean.codigoPais}" 
        binding="#{cc.uiSelectOneVoewl}" >
            <f:selectItem itemLabel="Aaaa" itemValue="a" />
            <f:selectItem itemLabel="Eeee" itemValue="e" />
            <f:selectItem itemLabel="Iiii" itemValue="i" />
            <f:selectItem itemLabel="Oooo" itemValue="o" />
            <f:selectItem itemLabel="Uuuu" itemValue="u" />
        <p:ajax event="change"  listener="#{cc.voewlAjaxListener}" update="consonantWrapper" />
    </p:selectOneMenu>

    <h:panelGroup id="consonantWrapper" layout="block">
        <p:selectOneMenu id="oneMenuConsonant"  value="#{cc.attrs.bean.codigoProvincia}"
            binding="#{cc.uiSelectOneConsonant}">
                <f:selectItem itemLabel="Bbbb" itemValue="b" />
                <f:selectItem itemLabel="Cccc" itemValue="c" />
                <f:selectItem itemLabel="Dddd" itemValue="d" />
        </p:selectOneMenu>

    </h:panelGroup>

</cc:implementation>

Bean

public class Direccion implements Serializable {
    private String codigoPais; /* with its getter and setter*/
    private String codigoProvincia; /* with its getter and setter*/

}

XHTML xhtml-: ( )

<sgnx:letter-example bean="#{controller.direccion}" />

@Named beans

@Named
@ViewScoped
public class P001DatosNotificacionController
    private Direccion direccion; /* with its getter and setter*/

@Named
@ViewScoped
public class P001GestionNotificacionesController
    private Direccion direccion; /* with its getter and setter*/

@Named
@ViewScoped
public class P002BandejaProvisionalNotificacionesController
    private Direccion direccion; /* with its getter and setter*/
+4
1

. .

@ViewScoped, javax.faces.bean javax.faces.view

. :

import javax.inject.Named;    
import javax.faces.bean.ViewScoped;

, , :

import javax.inject.Named;
import javax.faces.view.ViewScoped;

:

+2

Source: https://habr.com/ru/post/1685891/


All Articles