Class JcmsFormHandler

All Implemented Interfaces:
JcmsConstants, JaliosConstants
Direct Known Subclasses:
AbstractAutocompleteHandler, AbstractCaddyHandler, AbstractChooserHandler, AbstractFullCalendarActionHandler, AbstractQueryHandler, AccessTokenManagerHandler, AddGroupMembersHandler, AddJPortalServiceHandler, AdminHandler, AdminSearchEnginesHandler, AdminStartAnalysisHandler, AlertHandler, ApplicationAppModalHandler, ApplicationDefaultAppHandler, ApplicationDeployHandler, ApplicationLauncherActionsHandler, ApplicationQueryHandler, AssociatedPDFUploadHandler, AsyncShortcutHandler, AuditApplicationLauncherModal, AvoidanceLinkAdminEditHandler, BackgroundProcessHandler, BackOfficeActionHandler, BackOfficeDisplayHandler, CacheManagerHandler, CategoryCleanerHandler, CategoryListHandler, CheckIntegrityHandler, CheckRightsHandler, ClassificationAdminHandler, CompositePropertiesHandler, ContentSecurityPolicyAdminHandler, DashboardAppHandler, DataReportHandler, DBPublicationCategoriesCheckerHandler, DelegateConfirmModalHandler, DemoHandler, DemoModalHandler, DemoModalStepHandler, DisplayPluginHandler, DuplicateThemeHandler, EditAlertRuleHandler, EditDataHandler, EditFontHandler, EditImageHandler, EditLocalFontHandler, EditMailProviderHandler, EditMemberProfilingHandler, EditPaletteHandler, EditPluginHandler, EditWFHandler, EditWFRoleHandler, EditWFStateHandler, ExportCategoriesHandler, FavoriteWorkspaceHandler, FileProcessorAdminHandler, FriendlyURLsHandler, GroupDisplayHandler, GroupListHandler, IconChooserModalHandler, ImportConflictHandler, ImportManagerHandler, JBlockEditorHandler, JcmsJsonActionHandler, JcmsUploadFormHandler, JPortalDisplayHandler, JPortalEditorHandler, JPortalEditPorletHandler, JPortalEditPortletUIHandler, JPortalHistoryHandler, JSyncManagerHandler, LegacyWitnessFileImportHandler, LoggingSetupHandler, MailEditHandler, MailPasswordHandler, MediaActionsHandler, MediaInfosHandler, MediaStockQueryHandler, MediaTracksHandler, MemberAlertSettingsHandler, MemberDisplayHandler, MemberListHandler, MemberPhotoGroupModalHandler, MergeCategoryHandler, MergeFileDocumentHandler, ModalPromptHandler, MonitoringChartHandler, PluginDataInfosHandler, PortletDisplayHandler, PortletIndicatorDisplayHandler, PortletWorkflowHandler, ProcessL10nHandler, ProfilerHandler, PropertiesEditorHandler, PropertiesHandler, PubBrowserHandler, PublicationDisplayHandler, PublicationFollowerHandler, PublicationUnifiedInsertQueryHandler, PublicDownloadHandler, PublicLinkAppHandler, ReadAckHandler, ReaderTrackerQueryHandler, RecommendApplicationHandler, RecommendationHandler, RecommendationReaderTrackerHandler, RemoveGroupMemberHandler, ReportHandler, ResetApplicationLauncherModal, ResetPasswordHandler, SelectSubGroupsHandler, SendAlertHandler, SidebarHandler, SiteLanguageHandler, StoreAnonymizerHandler, StoreCleanerHandler, SyncLdapHandler, TemplateInitialisationHandler, ThemingToolAppHandler, ThumbnailActionsHandler, TopbarApplicationMenuBadgeHandler, TopbarCaddyMenuHandler, TopbarHandler, TrackerAppHandler, TranstypingHandler, TypeEditorHandler, TypeListEditorHandler, UnifiedInsertHandler, UploadPluginHandler, VersionHandler, WFEditorHandler, WFListHandler, WorkReportHandler, WorkspaceRoleListHandler, WorkspaceWizardHandler, WysiwygInlineEditionHandler

public abstract class JcmsFormHandler extends JcmsJspContext implements JcmsConstants
This abstract class is the super class of all the Form Handler classes (i.e. JavaBean classes used in JSP pages for processing form).

To implement a custom form handler :

  • Add setters to trigger custom operations,
  • Add setters for receive optional parameters,
  • Implement processAction() to check for any operation, validate precondition and perform action,
  • Create a JSP :
    • with the handler as a JavaBean
    • for which you'll invoke the validate() method

The following example demonstrate uses of a form handler to receive a firstname as an input and when validated display a Hello World message to the user

Java file com.example.jcmsplugin.hello.HelloWorldHandler.java:
 package com.example.jcmsplugin.hello;
 
 import java.io.IOException;
 
 import com.jalios.jcms.HttpUtil;
 import com.jalios.jcms.context.JcmsMessage;
 import com.jalios.jcms.context.JcmsMessage.Level;
 import com.jalios.jcms.handler.JcmsFormHandler;
 import com.jalios.util.Util;
 
 public class HelloWorldHandler extends JcmsFormHandler {
 
   // Possible operations
   private boolean opSayHello = false;
   private boolean opCancel = false;
 
   // Member variables
   private String firstname = null; 
 
   @Override
   public boolean processAction() throws IOException {
     
     if (validateSayHello()) {
       return performSayHello();
     }
 
     if (validateCancel()) {
       return performCancel();
     }
 
     return false;
   }
 
   // ---------------------------------------------------------------
   // Say Hello
   // ---------------------------------------------------------------
 
   public boolean validateSayHello() {
     if (!opSayHello) {
       return false;
     }
     if (Util.isEmpty(this.firstname)) {
       addMsg(new JcmsMessage(Level.WARN, glp("jcmsplugin.myplugin.myhandler.missing-firsname")));
       return false;
     }
     return true;
   }
 
   public boolean performSayHello() throws IOException {
     // In I18N properties : 
     //   jcmsplugin.myplugin.myhandler.say-hello: Hello {0} !
     //
     addMsgSession(request, new JcmsMessage(Level.INFO,  glp("jcmsplugin.myplugin.myhandler.say-hello", HttpUtil.encodeForHTML(firstname))));
     return false;
   }
 
   // ---------------------------------------------------------------
   // Cancel
   // ---------------------------------------------------------------
 
   public boolean validateCancel() {
     return opCancel;
   }
 
   public boolean performCancel() throws IOException {
     sendRedirect(Util.notEmpty(redirect) ? redirect : "index.jsp");
     return true;
   }
 
   // ---------------------------------------------------------------
   // Setters
   // ---------------------------------------------------------------
 
   public void setOpSayHello(String opSayHello) {
     this.opSayHello = true;
   }
 
   public void setOpCancel(String opCancel) {
     this.opCancel = true;
   }
 
 
   public String getFirstname() {
     return this.firstname;
   }
   public void setFirstname(String firstname) {
     this.firstname = firstname;
   }
 }
 
JSP sayHello.jsp:
 
 
 <%@ include file='/jcore/doInitPage.jspf' %><%
 %><jsp:useBean id="formHandler" scope="page" class="com.example.jcmsplugin.hello.HelloWorldHandler"><%
  %><jsp:setProperty name="formHandler" property="request" value="<%= request %>" /><%
  %><jsp:setProperty name="formHandler" property="response" value="<%= response %>" /><%
  %><jsp:setProperty name="formHandler" property="*" /><%
 %></jsp:useBean><%
 
   if (formHandler.validate()) {
     return;
   }
 
 
 
 %><%@ include file='/jcore/doEmptyHeader.jspf' %><%
 %><%@ include file='/jcore/doMessageBox.jspf' %>
 
 
 
 <div id='hello'>
  <form action="sayHello.jsp" name="sayHelloForm" method="post">
 
 
  
   <%-- Inputs --%>
   <jalios:field name="firstname" formHandler="<%= formHandler %>">
     <jalios:control />
   </jalios:field>
 
 
   
   <%-- Hidden Inputs --%>
   <jalios:control settings='<%= new HiddenSettings().name("redirect").value(formHandler.getRedirect()) %>' />
 
  
   
   <%-- Buttons --%>
   <jalios:button name="opSayHello" label="jcmsplugin.btn.sayhello" buttonType="<%= ButtonType.BUTTON_SUBMIT %>" css="btn btn-primary" />
   <jalios:button name="opCancel" label="ui.com.btn.cancel" buttonType="<%= ButtonType.BUTTON_SUBMIT %>" css="btn btn-default" />
 
 
   
  </form>
 </div>
 
 
 
 <%@ include file='/jcore/doEmptyFooter.jspf' %>
 
 
Data Handlers (handlers inheriting from EditDataHandler) must perform additionnal operation, see corresponding JavaDoc.
  • Field Details

    • redirect

      protected String redirect
    • noRedirect

      protected boolean noRedirect
    • noSendRedirect

      protected boolean noSendRedirect
    • redirectOnClosePopup

      protected boolean redirectOnClosePopup
    • workspaceForced

      protected boolean workspaceForced
    • popupEdition

      protected boolean popupEdition
    • editFieldSet

      protected HashSet<String> editFieldSet
    • contextMap

      protected HashMap<String,Object> contextMap
    • formStep

      protected int formStep
    • op

      protected boolean op
    • opPrevious

      protected boolean opPrevious
    • opNext

      protected boolean opNext
    • opFinish

      protected boolean opFinish
    • openTabId

      protected String openTabId
    • csrfValidationEnabled

      protected boolean csrfValidationEnabled
      Boolean indicating if CSRF validation should be performed (true, which is the default), or not (false).

      You can disable CSRF validation in your handler by setting this value to false in your own init() implementation. Warning : changing this behavior IS NOT RECOMMENDED. Use wisely. You can invoke validateCSRF() manually at another time.

      Since:
      jcms-10.0.6 / JCMS-9049 / SEC-199
  • Constructor Details

    • JcmsFormHandler

      public JcmsFormHandler()
  • Method Details

    • init

      protected void init()
      Method to implement if you need to initialize your handler from parameter received, prior to all security validation.

      You must absolutely not perform any action which modify data or site configuration.

      Therefore it is strongly recommend NOT TO implement this method, or use very wisely.

    • validate

      public final boolean validate() throws IOException
      Method invoked by JSP to validate all conditions (authorization, parameters, ...), and eventualy trigger the action that was requested to the handler.

      Override processAction() if you need to provide custom actions.

      Returns:
      true if a redirect was done, false otherwise
      Throws:
      IOException - if error occured during validate
      Since:
      jcms-7.1 in JcmsFormHandler (was in EditDataHandler), final since JCMS-6004
    • validateCSRF

      protected boolean validateCSRF()
      Returns:
      false if CSRF is enabled and JcmsJspContext.checkCSRF() failed, true otherwise.
      Since:
      jcms-10.0.6
    • mustSendForbiddenOnCSRF

      protected boolean mustSendForbiddenOnCSRF()
      Check behavior to apply on CSRF error.

      Default behavior is to send forbidden redirect, this method allows the redirection to be skipped and form to be displayed.

      Override with extreme precaution, if you want to display form on CSRF error, make sure user is authorized to access data manipulated.

      Returns:
      true to send forbidden (default), false to display form with current user data. In both case processAction is not invoked.
      Since:
      jcms-10.0.7 / SEC-208
    • afterValidation

      protected boolean afterValidation(boolean result) throws IOException
      Throws:
      IOException
    • processAction

      protected boolean processAction() throws IOException
      Method to be implemented to check/validate action to be performed and process them.

      Default implementation is to return false. No need to call super method.

      This method may NOT be invoked at all if security validation are not met.

      You must ensure your handler and JSP can work properly without any code invoked in this method.

      Returns:
      false if no redirection is needed, true otherwise
      Throws:
      IOException - IO Exception
    • getAvailableMainLanguage

      public String getAvailableMainLanguage()
    • showCancelButton

      public boolean showCancelButton()
      Check if the "Cancel" button should be displayed in step modal form.

      The default implementation of this method is to always return true.

      You can provide a custom FormHandler to override this behavior.

      See jcore/doStepButtons.jspf for use of this method.

      Returns:
      true to display the "Cancel" button, false to hide it
      Since:
      jcms-7.1.2 jcms-7.2 as requested by issue JCMS-3057
    • showNextButton

      public boolean showNextButton()
      Check if the "Next" button should be displayed in step modal form.

      The default implementation of this method is to return true unless the finish button is being displayed by method showFinishButton().

      You can provide a custom FormHandler to override this behavior.

      See jcore/doStepButtons.jspf for use of this method.

      Returns:
      true to display the "Next" button, false to hide it
    • showPreviousButton

      public boolean showPreviousButton()
      Check if the "Previous" button should be displayed in step modal form.

      The default implementation of this method is to return true if the current step (as returned by getFormStep() is higher than 0.

      You can provide a custom FormHandler to override this behavior.

      See jcore/doStepButtons.jspf for use of this method.

      Returns:
      true to display the "Previous" button, false to hide it
    • showFinishButton

      public boolean showFinishButton()
      Check if the "Finish" button should be displayed in step modal form.

      The default implementation of this method is to return true if the current step (as returned by getFormStep() is the last one (as compared with getFormStepCount().

      You can provide a custom FormHandler to override this behavior.

      See jcore/doStepButtons.jspf for use of this method.

      Returns:
      true to display the "Finish" button, false to hide it
    • getFormStepCount

      public int getFormStepCount()
      Retrieve the total number of steps used for edition when invoking this form handler.

      The default implementation of this method is to return 1, corresponding to one step (which means only 1 screen being displayed).

      You can provide a custom FormHandler to override this behavior.

      See jcore/doSteps.jspf for use of this method.

      Returns:
      the total number of steps in this formhandler
    • isFormStepClickable

      public boolean isFormStepClickable()
      Returns true if the form step are clickable.
      Returns:
      true if the form step are clickable.
      Since:
      jcms-10.0.5
    • getFormStepPrefixProp

      public String getFormStepPrefixProp()
      Returns:
      the prefix prop for the steps
      Since:
      jcms-9.0.0
    • getFormStepFinishLabel

      public String getFormStepFinishLabel()
      Returns:
      the label of the Finish button
      Since:
      jcms-9.0.0
    • getFormStepLabels

      public String[] getFormStepLabels(String userLang)
      Returns the label array for the steps.
      Parameters:
      userLang - the language
      Returns:
      the label array for the steps.
      Since:
      jcms-9.0.0
    • getFormStepHiddenFields

      public String getFormStepHiddenFields()
    • getFormStep

      public int getFormStep()
      Retrieve the current step of edition when invoking this form handler.

      See jcore/doSteps.jspf for use of this method.

      Returns:
      the current steps in this formhandler (starting at 0 and ending at getFormStepCount() - 1)
    • setFormStep

      public void setFormStep(int step)
      Set the current step of edition when invoking this form handler.
      Parameters:
      step - the current step (0 being the first one and getFormStepCount() - 1 being the last one)
    • getOpenTabId

      public String getOpenTabId()
      Return the id of the tab to open
      Returns:
      the open tab id if not null
      Since:
      11.0.0 / JCMS-11630
    • setOpenTabId

      public void setOpenTabId(String openTabId)
      Set id of the opened tab
      Parameters:
      openTabId - the DOM id of tab to open, value MUST only contains alphanumeric.
      Since:
      11.0.0 / JCMS-11333 / use of new tabs in publication edit form
    • validatePrevious

      protected boolean validatePrevious() throws IOException
      Throws:
      IOException
    • performPrevious

      protected boolean performPrevious() throws IOException
      Throws:
      IOException
    • validateNext

      protected boolean validateNext() throws IOException
      Throws:
      IOException
    • performNext

      protected boolean performNext() throws IOException
      Throws:
      IOException
    • validateFinish

      protected boolean validateFinish() throws IOException
      Throws:
      IOException
    • performFinish

      protected boolean performFinish() throws IOException
      Throws:
      IOException
    • getWorkspace

      public Workspace getWorkspace()
      Description copied from class: JcmsContext
      Retrieve the current Workspace variable for this context either from request if inFO or from session if in back office. Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).
      Overrides:
      getWorkspace in class JcmsContext
      Returns:
      the workspace (the one set by doInitPage.jsp)
    • isWorkspaceForced

      public boolean isWorkspaceForced()
    • setWorkspace

      public void setWorkspace(Workspace wspc)
    • setWs

      public void setWs(String v)
    • sendRedirect

      public void sendRedirect(String url, boolean checkRedirect) throws IOException
      Set the redirect in the response. If noRedirect has been set, this method set no redirection. If noSendRedirect has been set, put the request attribute "redirect" but do not call response.sendRedirect(). This may be useful when redirecting from a dynamically included JSP in the front-office (some AppServer throw an exception when setting/getting request attribute once the redirect has been put.)
      Parameters:
      url - the url to redirect to.
      checkRedirect - if true and if redirect attribute has been set, redirect on this url
      Throws:
      IOException - IO Exception
      Since:
      jcms-4.0
    • getClosePopupUrl

      protected String getClosePopupUrl()
    • sendRedirect

      public void sendRedirect(String url) throws IOException
      Redirect current request to given URL.
      Overrides JcmsContext.sendRedirect(String) to use behavior provided by sendRedirect(String, boolean).
      Overrides:
      sendRedirect in class JcmsContext
      Parameters:
      url - the url to redirect to.
      Throws:
      IOException - if an error occured while writing in response headers
      Since:
      jcms-4.0
      See Also:
    • getRedirect

      public String getRedirect()
      Get the value of redirect.
      Returns:
      Value of redirect.
    • setRedirect

      public void setRedirect(String url)
      Set the value of redirect.
      Parameters:
      url - Value to assign to redirect.
    • getModalRedirect

      public String getModalRedirect()
      Get the redirect value to be used in the modals with modalRedirect.jspf and the request attribute 'modal.redirect'.
      Returns:
      redirect value
      Since:
      jcms-9.0.4
    • setNoRedirect

      public void setNoRedirect(boolean noRedirect)
      Set the value of noRedirect.
      Parameters:
      noRedirect - Value to assign to noRedirect.
      Since:
      jcms-4.0
    • setNoSendRedirect

      public void setNoSendRedirect(boolean noSendRedirect)
      Set the value of noSendRedirect.
      Parameters:
      noSendRedirect - Value to assign to noSendRedirect.
      Since:
      jcms-4.0
    • setRedirectOnClosePopup

      public final void setRedirectOnClosePopup(boolean redirectOnClosePopup)
      Set whether the redirect value should be applied to the opener when closing the popup edition.
      The value set by this method will be used only when using popup edition (setPopupEdition(boolean)).
      Parameters:
      redirectOnClosePopup - if true, the redirect value (setRedirect(String)) will be provided to closePopup.jsp to redirect the opener. if false, the popup will simply be closed and the opener refreshed.
      Since:
      jcms-5.7
    • getRedirectOnClosePopup

      public final boolean getRedirectOnClosePopup()
      Return the value indicating whether the redirect value should be applied to the opener when closing the popup edition.
      Returns:
      true, when redirect value (setRedirect(String)) will be provided to closePopup.jsp to redirect the opener. false, if the popup will simply be closed and the opener refreshed.
      Since:
      jcms-5.7
    • processStatus

      protected boolean processStatus(ControllerStatus status) throws IOException
      Process the ControllerStatus: do nothing if OK, or send on forbidden, or put a warning message in the request.
      Parameters:
      status - the ControllerStatus to be processed
      Returns:
      true when status is OK, false if status was a failure (forbidden or anything else)
      Throws:
      IOException - if an error occurs
      Since:
      jcms-5.0.0
    • getControllerContext

      protected HashMap<String,Object> getControllerContext()
      Build a controller context. I.E. add request, response and loggedMember.
      Returns:
      the HashMap which contains the context
      Since:
      jcms-5.0.0
    • isFieldMissing

      protected boolean isFieldMissing(String field)
      Check if the given parameter is present in the query parameters
      Parameters:
      field - the field to be checked
      Returns:
      true if this field is present in the query parameters
      Since:
      jcms-5.0.0
    • setPopupEdition

      public void setPopupEdition(boolean v)
      Set where this form handler is being invoked in a popup.
      Parameters:
      v - true if handler is invoked in popup, false otherwise
      Since:
      jcms-5.0.0
    • isPopupEdition

      public boolean isPopupEdition()
      Returns:
      true if this form handler is invoked through a popup
      Since:
      jcms-5.0.0
    • setEditField

      public void setEditField(String[] v)
      Parameters:
      v - a set of field names to edit
      Since:
      jcms-5.0.0
    • getEditFieldSet

      public HashSet<String> getEditFieldSet()
      Returns:
      a set of field names being edited
      Since:
      jcms-5.0.0
    • isFieldEdition

      public boolean isFieldEdition(String field)
      Parameters:
      field - field name
      Returns:
      true if this handler is invoked to edit only some fields of the data
      Since:
      jcms-5.0.0
      See Also:
    • isPartialFieldEdition

      public boolean isPartialFieldEdition()
      Returns true if this is a partial field edition (i.e. front edition)
      Returns:
      true if this is a partial field edition.
      Since:
      jcms-5.5.0
    • updateUploadedFields

      protected void updateUploadedFields(String fieldName, String[] values, FileUploadOptions options)
      Perform upload then, replace all values with value MultipartRequest.MULTIPART_UPLOAD with the real File realtive path.
      Parameters:
      fieldName - the field name
      values - the field fake values
      options - upload options
      Since:
      jcms-10.0.6 / JCMS-8317
    • getMainLangValue

      protected String getMainLangValue(String[] array, boolean trim, boolean escape)
      Returns the first value (i.e. the main language value) from the given array (monovalued ML fields).
      Parameters:
      array - the array
      trim - if true trim the value
      escape - if true escape the value
      Returns:
      the first value from the array.
      Since:
      jcms-6.0.0
    • getMLMap

      protected HashMap<String,String> getMLMap(String[] array, boolean trim, boolean escape)
      Returns the ML map (i.e. the additionnal languages) filled with the values contained in the given array (monovalued ML fields).
      Parameters:
      array - the array
      trim - if true trim the values
      escape - if true escape the values
      Returns:
      the ML map filled with the values contained in the given array.
      Since:
      jcms-6.0.0
    • getMainLangValueArray

      protected String[] getMainLangValueArray(String[] array, boolean trim, boolean escape)
      Returns the first values (i.e. the main language value) from the given array (multivalued ML fields).
      Parameters:
      array - the array
      trim - if true trim the values
      escape - if true escape the values
      Returns:
      the first values from the array (i.e. the main language value) from the given array.
      Since:
      jcms-6.0.0
    • getMLMapArray

      protected HashMap<String,String[]> getMLMapArray(String[] array, boolean trim, boolean escape)
      Returns the ML map (i.e. the additionnal languages) filled with the values contained in the given array (multivalued ML fields).
      Parameters:
      array - the array
      trim - if true trim the values
      escape - if true escape the values
      Returns:
      the ML map filled with the values contained in the given array.
      Since:
      jcms-6.0.0
    • sanitize

      public static final String[] sanitize(TypeFieldEntry tfe, String[] unsafeInput)
      Sanitize the specified input strings for the usage of the specified field.

      Current implementation is as follow :

      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      unsafeInput - the unsafe input strings to be sanitized
      Returns:
      an array of safe strings
      Since:
      jcms-10.0.0
    • sanitize

      public static final String sanitize(TypeFieldEntry tfe, String unsafeInput)
      Sanitize the specified input string for the usage of the specified field.

      Current implementation is as follow :

      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      unsafeInput - the unsafe input string to be sanitized
      Returns:
      a safe string
      Since:
      jcms-10.0.0
    • getMonolingualValue

      protected static String getMonolingualValue(TypeFieldEntry tfe, String[] array)
      Return the first value from the given array, properly sanitized for usage in the specified field.

      This method must only be used for monolingual and monovalued field.

      Example :

        TypeFieldEntry myfieldTFE = channel.getTypeFieldEntry(MyType.class, "myfield", true);
        String myfield;
        public void setMyMonolingualAndMonovaluedField(String[] input) {
          myfield = getMonolingualValue(myfieldTFE, input);
        }
       
      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      array - the array
      Returns:
      the first value from the array, properly sanitized. May return null if specified array was null.
      Since:
      jcms-10.0.0
      See Also:
    • getMonolingualValueArray

      protected static String[] getMonolingualValueArray(TypeFieldEntry tfe, String[] array)
      Return the values from the given array, properly sanitized for usage in the specified field.

      Traling empty or null values are removed from array.

      This method must only be used for monolingual and monovalued field.

      Example :

        TypeFieldEntry myfieldTFE = channel.getTypeFieldEntry(MyType.class, "myfield", true);
        String[] myfield;
        public void setMyMonolingualAndMultivaluedField(String[] input) {
          myfield = getMonolingualValueArray(myfieldTFE, input);
        }
       
      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      array - the array
      Returns:
      the values from the array, properly sanitized. May return null if specified array was null.
      Since:
      jcms-10.0.0
      See Also:
    • getMultilingualMainValue

      public static String getMultilingualMainValue(TypeFieldEntry tfe, String[] array)
      Return the main value (ie: value of main site language) from the given array, properly sanitized for usage in the specified multilingual field.

      This method must only be used for multilingual and monovalued field.

      It must be used along with getMultilingualMLMap(TypeFieldEntry, String[]).

      Example :

        TypeFieldEntry myfieldTFE = channel.getTypeFieldEntry(MyType.class, "myfield", true);
        String myfield; // main value
        Map<String,String> myfieldMLMap; // ISO-639 language code to value 
        public void setMyMultilingualAndMonovaluedField(String[] input) {
          myfield = getMultilingualMainValue(myfieldTFE, input);
          myfieldMLMap = getMultilingualMLMap(myfieldTFE, input);
        }
       
      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      array - the string array input received from the end user
      Returns:
      the first value from the array, properly sanitized. May return null if specified array was null.
      Since:
      jcms-10.0.0
      See Also:
    • getMultilingualMLMap

      public static HashMap<String,String> getMultilingualMLMap(TypeFieldEntry tfe, String[] array)
      Return a language map (ISO-639 language code to value) of all values but the value corresponding main site language, extracted from the specified array, and properly sanitized for usage in the specified multilingual field.

      This method must only be used for multilingual and monovalued field.

      See complete example in getMultilingualMainValue(TypeFieldEntry, String[])

      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      array - the string array input received from the end user
      Returns:
      a language map (ISO-639 language code to value).
      Since:
      jcms-10.0.0
      See Also:
    • getMultilingualMainValueArray

      protected static String[] getMultilingualMainValueArray(TypeFieldEntry tfe, String[] array)
      Return the main values (ie: values of main site language) from the given array, properly sanitized for usage in the specified multilingual field.

      This method must only be used for multilingual and multivalued field.

      It must be used along with getMultilingualMLMapArray(TypeFieldEntry, String[]).

      Example :

        TypeFieldEntry myfieldTFE = channel.getTypeFieldEntry(MyType.class, "myfield", true);
        String[] myfield; // main values
        Map<String,String[]> myfieldMLMap; // ISO-639 language code to values 
        public void setMyMultilingualAndMultivaluedField(String[] input) {
          myfield = getMultilingualMainValueArray(myfieldTFE, input);
          myfieldMLMap = getMultilingualMLMapArray(myfieldTFE, input);
        }
       
      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      array - the string array input received from the end user
      Returns:
      the main values from the array, properly sanitized.
      Since:
      jcms-10.0.0
      See Also:
    • getMultilingualMLMapArray

      protected static HashMap<String,String[]> getMultilingualMLMapArray(TypeFieldEntry tfe, String[] array)
      Return a language map (ISO-639 language code to values) of all values but the value corresponding main site language, extracted from the specified array, and properly sanitized for usage in the specified multilingual field.

      This method must only be used for multilingual and monovalued field.

      See complete example in getMultilingualMainValueArray(TypeFieldEntry, String[])

      Parameters:
      tfe - the TypeFieldEntry of the data field for which input is being read. Set to null when working with field of non generated type.
      array - the string array input received from the end user
      Returns:
      a language map (ISO-639 language code to values).
      Since:
      jcms-10.0.0
      See Also:
    • mapStringArrayToMapStringList

      protected static HashMap<String,List<String>> mapStringArrayToMapStringList(Map<String,String[]> map)
      Convert a map contaning Array of String, into to a map containg List of String.
      Parameters:
      map - to convert
      Returns:
      the converted Map
      Since:
      jcms-10.0.0
    • mapStringListToMapStringArray

      protected static HashMap<String,String[]> mapStringListToMapStringArray(Map<String,List<String>> map)
      Convert a map contaning List of String, into to a map containg Array of String.
      Parameters:
      map - to convert
      Returns:
      the converted Map
      Since:
      jcms-10.0.0
    • getHiddenField

      public String getHiddenField(String name, String value)
    • getHiddenFieldML

      public String getHiddenFieldML(String name, HashMap<String,String> map)
    • getHiddenField

      public String getHiddenField(String name, Data value)
    • getHiddenField

      public String getHiddenField(String name, boolean value)
    • getHiddenField

      public String getHiddenField(String name, int value)
    • getHiddenField

      public String getHiddenField(String name, double value)
    • getHiddenField

      public String getHiddenField(String name, long value)
    • getHiddenField

      public String getHiddenField(String name, Date value)
    • getHiddenField

      public String getHiddenField(String name, Data[] array)
    • getHiddenField

      public String getHiddenField(String name, boolean[] array)
    • getHiddenField

      public String getHiddenField(String name, int[] array)
    • getHiddenField

      public String getHiddenField(String name, long[] array)
    • getHiddenField

      public String getHiddenField(String name, double[] array)
    • getHiddenField

      public String getHiddenField(String name, String[] array)
    • getHiddenField

      public String getHiddenField(String name, Collection<String> coll)
    • getHiddenField

      public String getHiddenField(String name, Date[] array)
    • getHiddenField

      public <T extends Data> String getHiddenField(String name, Set<T> set)
    • checkMissingField

      protected boolean checkMissingField(Object obj, String prop)
    • setOpPrevious

      public void setOpPrevious(String v)
    • setOpNext

      public void setOpNext(String v)
    • setOpFinish

      public void setOpFinish(String v)
    • canStartProcess

      protected ControllerStatus canStartProcess(BackgroundProcess process)
      Parameters:
      process - the process to check if loggedMember can start it
      Returns:
      true if loggedMember can starts this process
      Since:
      jcms-10.0.8 / JCMS-9179
    • startProcess

      protected CompletableFuture<Void> startProcess(BackgroundProcess process)
      Parameters:
      process - the process to start
      Returns:
      a CompletableFuture
      Since:
      jcms-10.0.8 / JCMS-9179
    • getBackgroundProcess

      public BackgroundProcess getBackgroundProcess()
      Returns:
      the backgroundProcess in request attribute
      Since:
      jcms-10.0.8 / JCMS-9179