更改selectonemenu值时更新Bean,而无需刷新页面

时间:2019-06-17 18:50:26

标签: jsf

我有selectonemenu,我想在更改selectonemenu的值时希望更新的Bean值显示我处于阻塞状态的一些代码,而无需提交和刷新页面,而这不会丢失其他值形式

我什么都没显示

我有selectonemenu块

<h:selectOneMenu id="categorieSelect"  value = "#{categorie.option}" 
valueChangeListener="#{categorie.categorieChanged}">
<f:selectItem itemValue="selection" itemLabel="Choisissez une  catégorie" noSelectionOption="true"/>
<f:selectItems value ="#{categorie.options}" var="categorieSelect" />
<f:ajax event="change" execute="@form"/></h:selectOneMenu>

我在c:choose中也有一些块,当selectonemenu的值更改时,我想显示该块

<c:choose>
                                    <c:when test="#{categorie.option == 'offreemploi'}">
                                        <div class="row">
                                            <p:outputLabel value="Type d'annonce *" class="outputelement" id="test3"></p:outputLabel>
                                        </div>
                                        <div class="row">
                                            <h:selectOneRadio id="typeannonce" required="#{not empty param[menucategorie.clientId]}"
                                                              requiredMessage="Le type d'annonce est obligatoire"
                                                              class="inputelement"
                                                              value="#{offreEmploi.typeannonce}" binding="#{typeannonce}">
                                                <f:selectItem itemValue="demande" itemLabel="Demande (Vous recherchez un emploi)" 
                                                              />

                                                <f:selectItem itemValue="offre" itemLabel="Offre (Vous recherchez un employé)" />
                                            </h:selectOneRadio>
                                        </div>
                                        <div class="row">
                                            <h:message for="typeannonce" class="message col-xs-12 col-sm-6 col-md-6 col-lg-6"/>
                                        </div>
                                        <div class="row">
                                            <h:outputText value="Intitulé du poste *" class="outputelement"></h:outputText>
                                        </div>
                                        <div class="row">
                                            <h:inputText id="intituleposte" binding="#{intituleposte}" required="#{not empty param[menucategorie.clientId]}"
                                                         requiredMessage="L'intitule du poste est obligatoire"
                                                         class="col-xs-12 col-sm-6 col-md-6 col-lg-6 inputelement"
                                                         value="#{offreEmploi.intituleposte}"></h:inputText>
                                        </div>
                                        <div class="row">
                                            <h:message for="intituleposte" class="message col-xs-12 col-sm-6 col-md-6 col-lg-6"/>
                                        </div>
                                        <div class="row">
                                            <h:outputText value="Description du poste *" class="outputelement"></h:outputText>
                                        </div>
                                            <div class="row">
                                                <h:inputTextarea id="descriptionposte" rows="10" cols="30" binding="#{descriptionposte}" required="#{not empty param[menucategorie.clientId]}"
                                                                 requiredMessage="La description du poste est obligatoire"
                                                                 class="col-xs-12 col-sm-6 col-md-6 col-lg-6 inputelement"
                                                                 value="#{offreEmploi.descriptionposte}"></h:inputTextarea>
                                            </div>
                                        <div class="row">
                                            <h:message for="descriptionposte" class="message col-xs-12 col-sm-6 col-md-6 col-lg-6"/>
                                        </div>
                                        <div class="row">
                                            <h:outputText class="outputelement" value="Photos : Une annonce avec photos est beaucoup plus consulté qu'une annonce sans photos"></h:outputText>
                                        </div>
                                        <div class="row">
                                            <h:outputText class="outputelement" value="Photo principal"></h:outputText>
                                            <p:fileUpload  mode="simple" class="inputelement"
                                                           value="#{photo.photo1}" binding="#{photo1}"/>
                                        </div>
                                        <div class="row">
                                            <h:outputText class="outputelement" value="Photo 2"></h:outputText>
                                            <p:fileUpload  mode="simple" class="inputelement"
                                                           value="#{photo.photo2}" binding="#{photo2}"/>
                                        </div>
                                        <div class="row">
                                            <h:outputText class="outputelement" value="Photo 3"></h:outputText>
                                            <p:fileUpload  mode="simple" class="inputelement"
                                                           value="#{photo.photo3}" binding="#{photo3}"/>
                                        </div>
                                    </c:when>
                                    <c:otherwise>Bonjour</c:otherwise>
                                </c:choose>

这是我的后援豆

@ManagedBean
@SessionScoped
public class Categorie implements Serializable{
String option; // +getter +setter
List<SelectItem> options; // +getter

public String getOption() {
    return option;
}

public void setOption(String selectedOption) {
    this.option = selectedOption;
}

public List<SelectItem> getOptions() {
    return options;
}

public void setOptions(List<SelectItem> options) {
    this.options = options;
}

public void categorieChanged(ValueChangeEvent e) { 

//assign new value to country 
option = e.getNewValue().toString();  
} 
public void changeCountry() {
//System.out.println("Selected country is: " + option.);
}

public Categorie() {
options = new ArrayList<SelectItem>();
SelectItemGroup group1 = new SelectItemGroup("EMPLOI");
group1.setSelectItems(new SelectItem[] {
    new SelectItem("offreemploi", "Offre d'emploi")
});
options.add(group1); 




}
public void save(){

}
}

0 个答案:

没有答案