Вопрос

I have a strange problem which I have been trying to fix for some time but am stuck in one place and don't quite understand what's going on here.

My index page looks like this:

<h:selectOneMenu id="selectMenu" value="#{indexBean.model.selected_id}" styleClass="indexItems">
    <f:selectItems value="#{indexBean.myModelValues}" />    
    <a4j:support event="onchange" reRender="peek" />        
</h:selectOneMenu> 
<br>
<h:outputText id="peek" value ="#{indexBean.model.selected_id}"/>
<br>
<a4j:commandButton value="Go to Form" action="form" styleClass="indexItems">
    <f:param name="selected" value="#{indexBean.model.selected_id}" />                                       
</a4j:commandButton>

The commandButton sends the user to a next page when I want to get the selected position from the selectOneMenu. The problem is that nothing is sent. When I select some value from the Menu the 'peek' outputText is rerendered properly and I can see the correct selection. However it is not sent to the next page and Bean. Surprisingly when I change the value of the parameter to a fixed String it works!!! So i.e. this:

<f:param name="selected" value="someValue1" />

Is read correctly in the next Bean!!! All of the beans are requested scoped with RichFaces @KeepAlive annotation (I tried without the annotation and it's the same). Ihave treied: -changing a4j:commandButton to h:commandLink or h:outputLink -changing indexBean.model.selected_id to indexBean.selected_id -finally changing the input source from h:selectOneMenu to h:inputText

Nothing helps - it is still the same - a hardcoded String is passed correctly to the next page, but when I try to use the expresion the parameter is always empty.

Here I post a snippet of the faces-config.xml:

<managed-bean>
    <managed-bean-name>indexBean</managed-bean-name>
    <managed-bean-class>id.webapp.beans.IndexBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
    <managed-bean-name>model</managed-bean-name>
    <managed-bean-class>id.webapp.beans.Model</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
    <managed-bean-name>formBean</managed-bean-name>
    <managed-bean-class>id.webapp.beans.FormBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
        <property-name>selectedValue</property-name>
        <value>#{param.selected}</value>
    </managed-property>
</managed-bean> 

Does any one have an idea why this doesn't work? I have used the managed-properties parameters like that in the past and it worked (meaning using some dynamically changed values not a static String).

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top