<?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 Document form validator: get mode in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/document-form-validator-get-mode/m-p/316914#M3915</link>
    <description>&lt;P&gt;I have a field validator method which needs to be able to distinguish between layout modes of "create" and "edit", and do slightly different validation in those cases.&lt;/P&gt;
&lt;P&gt;The best solution I have managed to find looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public void validateMyField(FacesContext context, UIComponent component, Object value) {
  boolean isCreateMode = 
    (context.getExternalContext().getRequestParameterMap().get("document_create") != null);

  if (isCreateMode)
    //...validation A...
  else
    //...validation B...

}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This lookup seems somewhat fragile; is there a better approach?
I thought about creating two different validator methods for create and edit, but when the &lt;EM&gt;layout&lt;/EM&gt; is in "create" or "edit" mode, the &lt;EM&gt;widget&lt;/EM&gt; is always in "edit" mode, so I can only define the one validator.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jun 2014 15:58:00 GMT</pubDate>
    <dc:creator>simmonsj_</dc:creator>
    <dc:date>2014-06-06T15:58:00Z</dc:date>
    <item>
      <title>Document form validator: get mode</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/document-form-validator-get-mode/m-p/316914#M3915</link>
      <description>&lt;P&gt;I have a field validator method which needs to be able to distinguish between layout modes of "create" and "edit", and do slightly different validation in those cases.&lt;/P&gt;
&lt;P&gt;The best solution I have managed to find looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;public void validateMyField(FacesContext context, UIComponent component, Object value) {
  boolean isCreateMode = 
    (context.getExternalContext().getRequestParameterMap().get("document_create") != null);

  if (isCreateMode)
    //...validation A...
  else
    //...validation B...

}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This lookup seems somewhat fragile; is there a better approach?
I thought about creating two different validator methods for create and edit, but when the &lt;EM&gt;layout&lt;/EM&gt; is in "create" or "edit" mode, the &lt;EM&gt;widget&lt;/EM&gt; is always in "edit" mode, so I can only define the one validator.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jun 2014 15:58:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/document-form-validator-get-mode/m-p/316914#M3915</guid>
      <dc:creator>simmonsj_</dc:creator>
      <dc:date>2014-06-06T15:58:00Z</dc:date>
    </item>
  </channel>
</rss>

