<?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: Hidden default value in text field in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324966#M11967</link>
    <description>&lt;P&gt;Note that this configuration is equivalent to not having any contribution since the widget mode always resolves to "hidden".&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jul 2015 15:41:22 GMT</pubDate>
    <dc:creator>Anahide_Tchertc</dc:creator>
    <dc:date>2015-07-24T15:41:22Z</dc:date>
    <item>
      <title>Hidden default value in text field</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324964#M11965</link>
      <description>&lt;P&gt;How can I set a default value "0" in a text field on create mode.
Here's what I've tried:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; &amp;lt;widget name="obsolete" type="text"&amp;gt;
                &amp;lt;labels&amp;gt;
                  &amp;lt;label mode="any"&amp;gt;Obsolete&amp;lt;/label&amp;gt;
                &amp;lt;/labels&amp;gt;
                &amp;lt;translated&amp;gt;false&amp;lt;/translated&amp;gt;
                &amp;lt;fields&amp;gt;
                  &amp;lt;field&amp;gt;bc:obsolete&amp;lt;/field&amp;gt;
                &amp;lt;/fields&amp;gt;
                &amp;lt;widgetModes&amp;gt;
    		      &amp;lt;mode value="any"&amp;gt;hidden&amp;lt;/mode&amp;gt;
    	        &amp;lt;/widgetModes&amp;gt;
    &amp;lt;/widget&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2015 12:16:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324964#M11965</guid>
      <dc:creator>Dalal_</dc:creator>
      <dc:date>2015-06-16T12:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Hidden default value in text field</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324965#M11966</link>
      <description>&lt;P&gt;Static default values can be declared in the schema:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xs:element name="obsolete" type="xs:int" default="0"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need to setup a dynamic value, you can create a listener like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;
@Name("MyCustomListener")
public class MyCustomListener implements EventListener {

	public void handleEvent(Event event) throws ClientException {
        DocumentEventContext docCtx = (DocumentEventContext) ctx;
    	DocumentModel doc = docCtx.getSourceDocument();
		if (doc != null) {
			if ("myCustomType".equals(doc.getType())) {
				doc.setPropertyValue("bc:obsolete", "myCustomValue");
			}
     		[...]
		}
	}
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;extension target="org.nuxeo.ecm.core.event.EventServiceComponent" point="listener"&amp;gt;
  &amp;lt;listener name="myCustomListener" async="false" postCommit="false"
    class="org.my.custom.package.myCustomListener"&amp;gt;
    &amp;lt;event&amp;gt;emptyDocumentModelCreated&amp;lt;/event&amp;gt;
  &amp;lt;/listener&amp;gt;
&amp;lt;/extension&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As an alternative, you can also try using a custom widget property with name "defaultValue":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;widget name="obsolete" type="text"&amp;gt;
  &amp;lt;labels&amp;gt;
    &amp;lt;label mode="any"&amp;gt;Obsolete&amp;lt;/label&amp;gt;
  &amp;lt;/labels&amp;gt;
  &amp;lt;translated&amp;gt;false&amp;lt;/translated&amp;gt;
  &amp;lt;fields&amp;gt;
    &amp;lt;field&amp;gt;bc:obsolete&amp;lt;/field&amp;gt;
  &amp;lt;/fields&amp;gt;
  &amp;lt;properties mode="any"&amp;gt;
    &amp;lt;property name="defaultValue"&amp;gt;0&amp;lt;/property&amp;gt;
  &amp;lt;/properties&amp;gt;
&amp;lt;/widget&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jul 2015 11:44:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324965#M11966</guid>
      <dc:creator>JVent_</dc:creator>
      <dc:date>2015-07-24T11:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Hidden default value in text field</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324966#M11967</link>
      <description>&lt;P&gt;Note that this configuration is equivalent to not having any contribution since the widget mode always resolves to "hidden".&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2015 15:41:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/hidden-default-value-in-text-field/m-p/324966#M11967</guid>
      <dc:creator>Anahide_Tchertc</dc:creator>
      <dc:date>2015-07-24T15:41:22Z</dc:date>
    </item>
  </channel>
</rss>

