0

我有一个奇怪的问题。我在我的 Web 应用程序中使用 JSF 2.1.7(最新版本),并且我有一个 JSF 必须在每个会话中管理的 bean。这是我的 bean 代码:

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);
}

}

我正在使用 ui:repeat 标记在 xhtml 页面中进行迭代,这就是奇怪的东西出现的地方。如您所见,我在变量名称前用取消标记定义了我的吸气剂。我的 xhtml 显示如下:

<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>

如果我使用给定的代码,它工作没有问题,但如果我折射 get_Navegabes 并将方法名称更改为 getNavegables,不带下划线,并在 xhtml 页面中执行相同操作,它会给我下一个错误:

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

所以 JSF 找不到该属性。我在此页面中使用的每个吸气剂都会发生这种情况,不知道为什么。有没有人尝试过类似的问题?

4

1 回答 1

1

value="#{navigationManager.Navegables}" 错误,"N" 不应该是大写,而是使用这个: value="#{navigationManager.navegables}"

于 2012-04-13T07:12:00.060 回答