<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: condition for Widget on create mode in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320445#M7446</link>
    <description>&lt;P&gt;Thank you [Greg Drayon](https&lt;/P&gt;</description>
    <pubDate>Tue, 08 Dec 2015 12:37:46 GMT</pubDate>
    <dc:creator>ITShine_</dc:creator>
    <dc:date>2015-12-08T12:37:46Z</dc:date>
    <item>
      <title>condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320441#M7442</link>
      <description>&lt;P&gt;I'm using Nuxeo IDE , and i want to display a drop down list in my creation layout form , this drop down list should be displayed only if another drop down list is filled with a certain value , can anyone show me how to do that , normally i should use JavaScript but i don't know how to use with my widgets . In  &lt;A href="https://doc.nuxeo.com/display/NXDOC/How+to+Make+a+Selection+Based+on+the+Value+of+Another+Value+in+a+Layout"&gt;this link&lt;/A&gt; i could find an example but only for Nuxeo studio&lt;/P&gt;
&lt;P&gt;With the code below, the drop down list is displayed only after saving the document, so we have to edit it in order to fill the field, but i want to have the drop down list displayed while i'm creating the document :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;widget name="civilite" type="suggestOneDirectory"&amp;gt;
        &amp;lt;labels&amp;gt;
          &amp;lt;label mode="any"&amp;gt;Civilité&amp;lt;/label&amp;gt;
        &amp;lt;/labels&amp;gt;
        &amp;lt;translated&amp;gt;true&amp;lt;/translated&amp;gt;
        &amp;lt;fields&amp;gt;
          &amp;lt;field&amp;gt;rens:civilite&amp;lt;/field&amp;gt;
        &amp;lt;/fields&amp;gt;
        &amp;lt;properties mode="any"&amp;gt;
          &amp;lt;property name="width"&amp;gt;300&amp;lt;/property&amp;gt;
          &amp;lt;property name="labelFieldName"&amp;gt;label_{lang}&amp;lt;/property&amp;gt;
          &amp;lt;property name="dbl10n"&amp;gt;true&amp;lt;/property&amp;gt;
          &amp;lt;property name="minChars"&amp;gt;0&amp;lt;/property&amp;gt;
          &amp;lt;property name="hideHelpLabel"&amp;gt;true&amp;lt;/property&amp;gt;
          &amp;lt;property name="directoryName"&amp;gt;civilite_directory&amp;lt;/property&amp;gt;
          &amp;lt;property name="keySeparator"&amp;gt;/&amp;lt;/property&amp;gt;
          &amp;lt;property name="placeholder"&amp;gt;Civilité&amp;lt;/property&amp;gt;
          &amp;lt;property name="documentSchemas"&amp;gt;dublincore,layout_demo_schema&amp;lt;/property&amp;gt;
          &amp;lt;property name="repository"&amp;gt;default&amp;lt;/property&amp;gt;
        &amp;lt;/properties&amp;gt;
        &amp;lt;controls mode="any"&amp;gt;
          &amp;lt;!-- enable ajax submit on change/click/select on demo application --&amp;gt;
          &amp;lt;control name="supportInsideInputWidgetEffects"&amp;gt;true&amp;lt;/control&amp;gt;
	&amp;lt;/controls&amp;gt;
	&amp;lt;widgetModes&amp;gt;
		  &amp;lt;mode value="any"&amp;gt;#{layoutValue.rens.statut=='Prospect'?'create':'hidden'}&amp;lt;/mode&amp;gt;
		&amp;lt;/widgetModes&amp;gt;
    &amp;lt;/widget&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;**Here is what i have in my layout : **&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;widget name="civilite" type="template"&amp;gt;
        &amp;lt;labels&amp;gt;
          &amp;lt;label mode="any"&amp;gt;
            Civilité 
          &amp;lt;/label&amp;gt;
        &amp;lt;/labels&amp;gt;
        &amp;lt;helpLabels&amp;gt;
          &amp;lt;label mode="any"&amp;gt;
            label.local.configuration.theme.flavorSelection.help
          &amp;lt;/label&amp;gt;
        &amp;lt;/helpLabels&amp;gt;
        &amp;lt;translated&amp;gt;true&amp;lt;/translated&amp;gt;
        &amp;lt;fields&amp;gt;
          &amp;lt;field&amp;gt;rens:civilite&amp;lt;/field&amp;gt;
        &amp;lt;/fields&amp;gt;
        &amp;lt;properties mode="any"&amp;gt;
          &amp;lt;property name="template"&amp;gt;
            /widgets/select_flavor_widget_template.xhtml
          &amp;lt;/property&amp;gt;
           
          
      &amp;lt;/widget&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;**For displaying values of the first drop down list in JSF , i've done this : **
select_flavor_widget_template.xhtml&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;h:form&amp;gt;
  &amp;lt;h:panelGrid columns="3" styleClass="dataInput"
      columnClasses="labelColumn, fieldColumn, fieldColumn"&amp;gt;
      
	 &amp;lt;h:selectOneMenu id="thekeywords" value="#{field}"&amp;gt;
        &amp;lt;f:selectItems value="#{ocrManager.availableCivilites}" /&amp;gt;
      &amp;lt;/h:selectOneMenu&amp;gt;
      &amp;lt;h:commandButton action="#{ocrManager.changeData}"
        value="Valider" /&amp;gt;
	&amp;lt;/h:panelGrid&amp;gt;
 &amp;lt;/h:form&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;and in bean :&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;private String civilite;
    protected List&amp;lt;SelectItem&amp;gt; civiliteList;
    
    public String getCivilite() {
        if (civilite == null) {
            return "";
        } else {
            return civilite;
        }
    }

    public void setCivilite(String s) {
    	civilite = s;
    }

    public List&amp;lt;SelectItem&amp;gt; getAvailableCivilites() throws ClientException {
        if (civiliteList == null) {
            computeciviliteValues();
        }
        return civiliteList;
    }
    
    private void computeciviliteValues() throws ClientException {
        DirectoryService dirService;
        try {
           
            dirService = Framework.getLocalService(DirectoryService.class);
        } catch (Exception e) {
            throw new ClientException(e);
        }

        Session dir = null;
        try {
            dir = dirService.open("civilite_directory");
            DocumentModelList entries = dir.getEntries();
            civiliteList = new ArrayList&amp;lt;SelectItem&amp;gt;(entries.size());
            for (DocumentModel e : entries) {
                String value = (String) e.getProperty("civilite", "id");
                String label = (String) e.getProperty("civilite", "label_fr");
                SelectItem item = new SelectItem(value, label);
                civiliteList.add(item);
            }
        } finally {
            if (dir != null) {
                dir.close();
            }
        }
    }
    @Observer(value = { EventNames.DOCUMENT_SELECTION_CHANGED }, create = false)
    public void resetCiviliteValues() {
    }
public void changeData() throws ClientException {
        
    		DocumentModel doc = navigationContext.getCurrentDocument();
        	
        	// create an empty document model (this object is created in memory - it is not yet stored in the repository)
        	DocumentModel document = documentManager.createDocumentModel(doc.getPathAsString(), title, "renseignements");
        	
        	// now set some basic properties like a title and a description.
        	
            
            document.setProperty("renseignements", "civilite", civilite);

            documentManager.saveDocument(document);
    	    documentManager.save();
    		
        }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;So now the value of the first drop down list is saved in &lt;CODE&gt;rens:civilite&lt;/CODE&gt; , now i'm looking for a way to change dynamically the  visibility of the second drop down list based on the the value of the first one and how i should add in my layout in order to be saved in &lt;CODE&gt;rens:nbrenfants&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 10:32:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320441#M7442</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-03T10:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320442#M7443</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It seems that you are looking for &lt;A href="https://doc.nuxeo.com/x/Phw5AQ" target="test_blank"&gt;https://doc.nuxeo.com/x/Phw5AQ&lt;/A&gt; (if you'd like the drop down to be displayed or hidden in Ajax in the current view).&lt;/P&gt;
&lt;P&gt;Using JavaScript to hide or show the widget would not make it possible to control the field validation (in case the value is required for instance, if the widget is hidden only in JavaScript, this validation would still be performed).
That is why this documentation is using Ajax requests to show or hide the widget in the page.&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 09:13:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320442#M7443</guid>
      <dc:creator>Anahide_Tchertc</dc:creator>
      <dc:date>2015-12-04T09:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320443#M7444</link>
      <description>&lt;P&gt;Thank you [Anahide Tchertchian](https&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 17:35:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320443#M7444</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-07T17:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320444#M7445</link>
      <description>&lt;P&gt;There aren't that many used classes, if you look at the [first use case](https&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 08:54:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320444#M7445</guid>
      <dc:creator>Greg_Drayon</dc:creator>
      <dc:date>2015-12-08T08:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320445#M7446</link>
      <description>&lt;P&gt;Thank you [Greg Drayon](https&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 12:37:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320445#M7446</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-08T12:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320446#M7447</link>
      <description>&lt;P&gt;At first sight, I would say that your the keywords selectOneMenu is linked to your bean for its value, but is not linked to a metada property to be saved.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 14:38:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320446#M7447</guid>
      <dc:creator>Greg_Drayon</dc:creator>
      <dc:date>2015-12-08T14:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320447#M7448</link>
      <description>&lt;P&gt;[Greg Drayon](https&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:21:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320447#M7448</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-08T15:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320448#M7449</link>
      <description>&lt;P&gt;I think a little more information is need about how you want it to work.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 08:44:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320448#M7449</guid>
      <dc:creator>Greg_Drayon</dc:creator>
      <dc:date>2015-12-09T08:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320449#M7450</link>
      <description>&lt;P&gt;Thank you [Greg Drayon](https&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 09:13:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320449#M7450</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-09T09:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320450#M7451</link>
      <description>&lt;P&gt;Thank you so much [Greg Drayon](https&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 16:51:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320450#M7451</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-09T16:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320451#M7452</link>
      <description>&lt;P&gt;Maybe something like this? It's just a rough draft.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 08:47:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320451#M7452</guid>
      <dc:creator>Greg_Drayon</dc:creator>
      <dc:date>2015-12-10T08:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320452#M7453</link>
      <description>&lt;P&gt;My bad, it was a copy/paste mistake. I edited to what I think should do the trick. I have to say that I don't have what to test right know, nor do I know what selectedCiviliteValue hold as value. So "ocrManager.getCiviliteById()" is just a guess of what should be used.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 08:51:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320452#M7453</guid>
      <dc:creator>Greg_Drayon</dc:creator>
      <dc:date>2015-12-10T08:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: condition for Widget on create mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320453#M7454</link>
      <description>&lt;P&gt;I'll try it, thank you [Greg Drayon](https&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 11:38:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-for-widget-on-create-mode/m-p/320453#M7454</guid>
      <dc:creator>ITShine_</dc:creator>
      <dc:date>2015-12-10T11:38:37Z</dc:date>
    </item>
  </channel>
</rss>

