简体   繁体   中英

JSF bean access failing

I have a strange problem. I'm using JSF 2.1.7 (latest one) in my web app, and I have a bean which JSF has to manage per session. That's my bean code:

public abstract class NavegableManager<E> implements INavegableManager<E> {

/**
 * 
 */
private static final long serialVersionUID = 1L;

// Propiedad que controla la habilitación-desabilitación de los botones de navegación
private boolean _DisableNavigationButtons;

/**
 * 
 */
private final Stack<INavegable<E>> _NavegableStack;

/**
 * Constructor
 */
public NavegableManager() {
    super();
    this._NavegableStack = new Stack<INavegable<E>>();
}

/**
 * Limpia los navegables almacenados en el manager y se quita de la sesión
 * 
 * @throws Throwable
 */
public void clear() throws Throwable {
    while (!this._NavegableStack.isEmpty()) {
        INavegable<E> nav = this._NavegableStack.pop();
        nav.clear();
    }
}

/*
 * (non-Javadoc)
 * 
 * @see
 * com.tesicnor.navigator.event.INavegableListener#eventNewNavegable(com.tesicnor.navigator.event.NavegableEvent)
 */
@Override
public void eventNewNavegable(NavegableEvent event) throws NavegableServiceException {
    if (event.getNavegable() != null) {
        // Se asigna al navegable el mismo servicio que el navegable anterior
        event.getNavegable().set_Service(this._NavegableStack.peek().get_Service());
        this.push(event.getNavegable());
    }
}

/*
 * (non-Javadoc)
 * 
 * @see
 * com.tesicnor.navigator.event.INavegableListener#eventRemoveNavegable(com.tesicnor.navigator.event.NavegableEvent)
 */
@Override
public void eventRemoveNavegable(NavegableEvent event) {
    if (this._NavegableStack.contains(event.getSource())) {
        boolean mustUnFreezePeek = event.getSource() == this._NavegableStack.peek();
        this._NavegableStack.remove(event.getSource());
        event.getSource().unRegister(this);
        event.getSource().clear();

        if (mustUnFreezePeek && !this._NavegableStack.isEmpty())
            this._NavegableStack.peek().unFreeze();
    }
}

/*
 * (non-Javadoc)
 * 
 * @see
 * com.tesicnor.navigator.event.INavegableListener#eventSelectNavegable(com.tesicnor.navigator.event.NavegableEvent)
 */
@Override
public void eventSelectNavegable(NavegableEvent event) throws NavegableServiceException {
    while (!this._NavegableStack.isEmpty() && !this._NavegableStack.peek().equals(event.getSource()))
        this.pop();
    if (this._NavegableStack.isEmpty())
        this.push(event.getSource());
    this.get_Navegable().unFreeze();
}

@Override
public synchronized INavegable<E> get_Navegable() {
    if (!this._NavegableStack.isEmpty())
        return this._NavegableStack.peek();
    else
        return null;
}

@Override
public List<INavegable<E>> get_Navegables() {
    return this._NavegableStack.subList(0, this._NavegableStack.size() - 1);
}

public boolean is_DisableNavigationButtons() {
    return this._DisableNavigationButtons;
}

/**
 * 
 * @return
 */
public boolean is_init() {
    return true;
}

/**
 * Indica si debe mostrarse el menu de navegacion. Solo se muestra si hay más de 1 elemento de navegacion
 * 
 * @return
 */
public boolean is_ShowNavegacion() {
    return this._NavegableStack.size() > 1;
}

/*
 * (non-Javadoc)
 * 
 * @see com.tesicnor.navigator.INavegableManager#isInit()
 */
@Override
public boolean isInit() {
    return false;
}

/**
 * 
 * @throws EmptyStackException
 */
private synchronized void pop() throws EmptyStackException {
    INavegable<E> peek = this._NavegableStack.pop();
    peek.unRegister(this);
    peek.clear();
}

/*
 * (non-Javadoc)
 * 
 * @see com.tesicnor.navigator.INavegableManager#push(com.tesicnor.navigator.INavegable)
 */
private synchronized void push(INavegable<E> navegable) throws NavegableServiceException {
    INavegable<E> peek = this.get_Navegable();
    navegable.register(this);
    this._NavegableStack.push(navegable);
    if (peek != null)
        peek.freeze();
}

/**
 * Propiedad que controla la habilitación-desabilitación de los botones de navegación
 * 
 * @param _disableNavigationButtons
 */
public void set_DisableNavigationButtons(boolean _disableNavigationButtons) {
    this._DisableNavigationButtons = _disableNavigationButtons;
}

/*
 * (non-Javadoc)
 * 
 * @see com.tesicnor.navigator.INavegableManager#setNavegable(com.tesicnor.navigator.INavegable)
 */
@Override
public void setNavegable(INavegable<E> navegable) throws NavegableServiceException {
    while (!this._NavegableStack.isEmpty())
        this.pop();
    this.push(navegable);
}

}

I'm doing an iteration in a xhtml page using ui:repeat tag, and here is where the strange stuff comes on. As you can see, I have my getters defined with an undescore before the name of the variable. My xhtml shows like that:

<h:form>
    <!--            <p:queue requestDelay="1" ignoreDupResponce="true" /> -->
    <h:panelGroup id="navigationPanel">
        <!-- Comprobar si está activada la deshabilitación de los botones de navegación -->
        <h:panelGroup
            rendered="#{!navigationManager._DisableNavigationButtons}">
            <ui:repeat value="#{navigationManager._Navegables}" var="item">
                <p:commandButton value="#{item._Title}"
                    action="#{item.actionSelected}" update="#{reRenderOnSelect}" />
            </ui:repeat>
            <p:commandButton disabled="true"
                value="#{navigationManager._Navegable._Title}" />
        </h:panelGroup>
        <h:panelGroup
            rendered="#{navigationManager._DisableNavigationButtons}">
            <ui:repeat value="#{navigationManager._Navegables}" var="item">
                <p:commandButton value="#{item._Title}"
                    listener="#{item.actionSelected}" update="#{reRenderOnSelect}"
                    disabled="true" />-->
            </ui:repeat>
            <p:commandButton disabled="true"
                value="#{navigationManager._Navegable._Title}" />
        </h:panelGroup>

    </h:panelGroup>
</h:form>

If I use given code it's working with no problems, but if I refractor get_Navegabes and change the method name to getNavegables, without underscore, and doing the same in the xhtml page, it's giving me the next error:

/system/navigation/navigation.xhtml @17,67 value="#{navigationManager.Navegables}": Property 'Navegables' not found on type com.tesicnor.system.view.navigation.NavigationManagerSystem

So JSF cannot find the property. It happens to every single getter I'm using in this page, don't know why. Has anybody experimented a similar problem??

value =“#{navigationManager.Navegables}”是错误的,“ N”不应为大写,而应使用:value =“#{navigationManager.navegables}”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM