cancel
Showing results for 
Search instead for 
Did you mean: 

condition for selectOneMenu not working on edit tab

ITShine_
Star Contributor
Star Contributor

I'm using the following code to display some drop down lists based on condition , it's working fine when creating a document but when trying to modify the documents , the select doesn't change i keep getting the first value . I'm using Nuxeo 7.10 Here is the code i'm using :

<div xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:t="http://myfaces.apache.org/tomahawk"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  xmlns:nxd="http://nuxeo.org/nxweb/document"
  xmlns:nxh="http://nuxeo.org/nxweb/html"
  xmlns:nxdir="http://nuxeo.org/nxdirectory"
  xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
<h:head>

</h:head>
<h:form >
  
      
	 <h:selectOneMenu id="thekeywords" value="#{field}">
		<f:selectItem itemLabel="Sélectionner une valeur" />
		<f:selectItem itemValue="Techniques de l’entreprise" itemLabel="Techniques de l’entreprise" />
		<f:selectItem itemValue="Développement du dirigeant" itemLabel="Développement du dirigeant" />
		<f:selectItem itemValue="Environnement de l’entreprise" itemLabel="Environnement de l’entreprise" />
		<f:selectItem itemValue="Management" itemLabel="Management" />
        <f:ajax render="tables" />
      </h:selectOneMenu>
      <h:panelGroup id="tables">
      <h:outputLabel for="#{widget.id}_tech" rendered="#{field == 'Techniques de l’entreprise'}" >Nature </h:outputLabel>
     
	 <h:selectOneMenu id="#{widget.id}_tech" value="#{field_1}" rendered="#{field == 'Techniques de l’entreprise'}">
		<f:selectItem itemLabel="Sélectionner une valeur" />
		<f:selectItem itemValue="Stratégie" itemLabel="Stratégie" />
		<f:selectItem itemValue="Ressources Humaines" itemLabel="Ressources Humaines" />
		<f:selectItem itemValue="Marketing" itemLabel="Marketing" />
		<f:selectItem itemValue="Commercial" itemLabel="Commercial" />
		<f:selectItem itemValue="Nouvelles Technologies" itemLabel="Nouvelles Technologies" />
		<f:selectItem itemValue="Finance et Fiscalité" itemLabel="Finance et Fiscalité" />
		<f:selectItem itemValue="Gouvernance" itemLabel="Gouvernance" />
        <f:ajax render="tables" />
      </h:selectOneMenu>
    
    <h:outputLabel for="#{widget.id}_dev" rendered="#{field == 'Développement du dirigeant'}">Nature </h:outputLabel>
     
	 <h:selectOneMenu id="#{widget.id}_dev" value="#{field_1}" rendered="#{field == 'Développement du dirigeant'}">
		<f:selectItem itemLabel="Sélectionner une valeur" />
		<f:selectItem itemValue="Connaissance de soi" itemLabel="Connaissance de soi" />
		<f:selectItem itemValue="Développer ses savoirs faire" itemLabel="Développer ses savoirs faire" />
		<f:selectItem itemValue="Développer son Équilibre personnel" itemLabel="Développer son Équilibre personnel" />
		<f:ajax render="tables" />
      </h:selectOneMenu>
	 
    <h:outputLabel for="#{widget.id}_env" rendered="#{field == 'Environnement de l’entreprise'}">Nature </h:outputLabel>
    
	  <h:selectOneMenu id="#{widget.id}_env" value="#{field_1}" rendered="#{field == 'Environnement de l’entreprise'}">
		<f:selectItem itemLabel="Sélectionner une valeur" />
		<f:selectItem itemValue="Changement et Transformation" itemLabel="Changement et Transformation" />
		<f:selectItem itemValue="Géopolitique" itemLabel="Géopolitique" />
		<f:selectItem itemValue="Prospective" itemLabel="Prospective" />
		<f:selectItem itemValue="Culture Générale" itemLabel="Culture Générale" />
		<f:selectItem itemValue="Créativité" itemLabel="Créativité" />
		<f:selectItem itemValue="Innovation" itemLabel="Innovation" />
        <f:ajax render="tables" />
      </h:selectOneMenu>

	 <h:outputLabel for="#{widget.id}_mng" rendered="#{field == 'Management'}">Nature </h:outputLabel>
     
    <h:selectOneMenu id="#{widget.id}_mng" value="#{field_1}" rendered="#{field == 'Management'}">
		<f:selectItem itemLabel="Sélectionner une valeur" />
		<f:selectItem itemValue="Comportement" itemLabel="Comportement" />
		<f:selectItem itemValue="Leadership" itemLabel="Leadership" />
		<f:selectItem itemValue="Organisation" itemLabel="Organisation" />
		<f:selectItem itemValue="Négociation" itemLabel="Négociation" />
		<f:selectItem itemValue="Changement" itemLabel="Changement" />
        <f:ajax render="tables" />
      </h:selectOneMenu>
    </h:panelGroup>
    
 </h:form>


  


  

  


  


  
</div>

In the console i'm getting those errors :


Failed to load resource: the server responded with a status of 404 (Introuvable)
'webkitMovementX' is deprecated. Please use 'movementX' instead. :8080/ged/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.5.0.Alpha3/PackedCompressed/org.richfaces/jquery.js:78 
'webkitMovementY' is deprecated. Please use 'movementY' instead. :8080/ged/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.5.0.Alpha3/PackedCompressed/org.richfaces/jquery.js:78 
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/. :8080/ged/javax.faces.resource/jsf.js.faces?ln=javax.faces:1 
default.js:6043 Uncaught TypeError: jQuery(...).initTipsy is not a function
(program):3 Uncaught TypeError: jQuery(...).focusFirst is not a function

Update

Here is the code i'm using to display the select widget :

<widget name="rubrique" type="template">
        <labels>
          <label mode="any">
            Rubrique 
          </label>
          
        </labels>
        
        <translated>true</translated>
        <fields >
          <field>rens:rubrique</field>
          <field>rens:nature</field>
        </fields>
        <properties mode="any">
          <property name="template">
            /widgets/select_flavor_widget_temp.xhtml
          </property>
           
          
        </properties>
      </widget>
1 ACCEPTED ANSWER

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

You should get rid of the h:form tag: it seems that you have two nested forms, since the edit layout is already surrounded by a h:form tag, and this could produce strange behaviors. The h:head tag should be removed too.

View answer in original post

21 REPLIES 21

ITShine_
Star Contributor
Star Contributor

[Greg Drayon](https

Greg_Drayon
Star Contributor
Star Contributor

OK, I clearly missed the hint. So you want the 2nd dropdown list to change when you change the value of the 1st one, without reloading the page nor saving the document? Like with some Ajax process?

ITShine_
Star Contributor
Star Contributor

[Greg Drayon](https

Greg_Drayon
Star Contributor
Star Contributor

Got it. Yes, it won't do. When you create the document, the "field_1" has no value. Whe you save, the value is registered and you can see the second drop down list in the edition form because it is calculated to be displayed server side. I guess if you set a news value in the first drop down list, then save, then try to edit again, the second drop down list if correctly updated? If so, it's because the new value is not sent to the server before your sabing, and the page is not recalculated. You should check [this page](https

ITShine_
Star Contributor
Star Contributor

[Greg Drayon](https

Greg_Drayon
Star Contributor
Star Contributor

It can. But there is no Ajax in your given code.

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

Can you try getting rid of the h

Greg_Drayon
Star Contributor
Star Contributor

My bad, I hadn't seen the "f

ITShine_
Star Contributor
Star Contributor

Thank you [Greg Drayon](https

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

Can you please share what you had to change to make it working?