Class AbstractPropertyUI<C extends IJspUIContext>

java.lang.Object
com.jalios.jcms.member.profile.ui.AbstractPropertyUI<C>
Type Parameters:
C - type of context
All Implemented Interfaces:
IJspUI<C>, IUI<C>
Direct Known Subclasses:
AbstractPropertyUIList, AbstractPropertyUIListItem

public abstract class AbstractPropertyUI<C extends IJspUIContext> extends Object implements IJspUI<C>
An user interface (UI) rendered by a JSP, and an optional label.

Instances are loaded using JProperties given a property prefix.

Custom fields can be implemented by providing getters (eg: isEnabled() and ENABLED_PROP_SUFFIX).

Example of UI configuration:

 # property prefix: foo.ui.foo-ui
 foo.ui.foo-ui.jsp: plugin/FooPlugin/jsp/foo-ui.jsp
 foo.ui.foo-ui.enabled: true | false
 
Subclass to provide custom fields like:
 # custom property
 foo.ui.foo-ui.bar: baz
 
Since:
jplatform-11
Author:
Sylvain Devaux
  • Field Details

    • LOGGER

      protected static final org.apache.log4j.Logger LOGGER
    • ENABLED_PROP_SUFFIX

      public static final String ENABLED_PROP_SUFFIX
      Sub property for "enabled/disabled" state.
      See Also:
    • ENABLED_REQ_ATTR

      protected static final String ENABLED_REQ_ATTR
      Request attr. name to disabled UI at runtime.
    • JSP_PROP_SUFFIX

      public static final String JSP_PROP_SUFFIX
      Sub property to declare jsp path.
      See Also:
  • Constructor Details

    • AbstractPropertyUI

      public AbstractPropertyUI(String property, C context)
      Inits .jsp sub properties.

      Example: if propertyIdentifier is jcmsplugin.foo.foo-ui, it will resolve:

       jcmsplugin.foo.foo-ui.jsp: path/to/foo.jsp
       
      Parameters:
      property - property prefix
      context - init context
      Throws:
      IllegalArgumentException - if property is null
      See Also:
    • AbstractPropertyUI

      public AbstractPropertyUI(AbstractPropertyUI<C> other)
  • Method Details

    • canInclude

      public boolean canInclude()
      Specified by:
      canInclude in interface IJspUI<C extends IJspUIContext>
      Returns:
      true if JSP file exists.
    • isEnabled

      public boolean isEnabled(javax.servlet.http.HttpServletRequest request)
      Returns weither UI should be displayed or not.

      Can be skipped using request using disable(HttpServletRequest).

      Parameters:
      request - current request
      Returns:
      true (by default) to validate UI can be rendered
      See Also:
    • getProperty

      public String getProperty()
    • getContext

      public C getContext()
      Specified by:
      getContext in interface IJspUI<C extends IJspUIContext>
      Returns:
      the context
    • getId

      public String getId()
      Specified by:
      getId in interface IJspUI<C extends IJspUIContext>
      Returns:
      ui identifier
      See Also:
    • getJsp

      public String getJsp()
      Returns JSP path from sub properties.
      Specified by:
      getJsp in interface IJspUI<C extends IJspUIContext>
      Returns:
      relative path of JSP file to render UI.
      See Also:
    • getLabel

      public String getLabel(String userLang)
      Resolve the label from the exact same property but located in lang prop files
      Parameters:
      userLang - the lang to resolve the label
      Returns:
      the label if defined in lang properties
    • setLabel

      public void setLabel(String label)
    • isEnabled

      public boolean isEnabled()
      Allow to skip UI rendering by property configuration (See ENABLED_PROP_SUFFIX).
      Specified by:
      isEnabled in interface IUI<C extends IJspUIContext>
      Returns:
      true to allow this ui
    • disable

      public void disable(javax.servlet.http.HttpServletRequest request)
      Allow to skip this UI using custom request attribute.
      Parameters:
      request - current request
    • canIncludeJsp

      protected boolean canIncludeJsp(String jsp, String property)
      Parameters:
      jsp - the jsp path
      property - jsp property (For logging purpose)
      Returns:
      true in case of JUnit.
    • canIncludeJsp

      protected boolean canIncludeJsp(String jsp, String property, boolean validateExists)
      Parameters:
      jsp - the jsp path
      property - jsp property (For logging purpose)
      validateExists - will validate a JSP file exist relatively from the webapp
      Returns:
      true in case of JUnit.
    • getPropertyKey

      public String getPropertyKey(String suffix)
      Computes a property key based on getProperty() and given suffix, appended after a ".".

      Eg: suffix="index" and property="foo.ui.foo"-> returns "foo.ui.foo.index"

      Parameters:
      suffix - the subproperties' suffix
      Returns:
      a full property with given suffix
    • getProperty

      public String getProperty(String property, String defaultValue)
    • getPropertyValue

      public String getPropertyValue(String suffix)
      Defaults on property's key when not translated to help debug
      Parameters:
      suffix - prop suffix
      Returns:
      value bound to property.suffix
    • getRealPath

      protected String getRealPath(String relativeFilePath)
    • getPropertyValue

      public String getPropertyValue(String suffix, String defaultValue)
    • getIntegerProperty

      public int getIntegerProperty(String suffix, int defaultValue)
    • getBooleanPropertyValue

      public boolean getBooleanPropertyValue(String suffix, boolean defaultValue)
    • getLangProperty

      public String getLangProperty(String userLang, String suffix)
    • logPrefix

      protected String logPrefix(String methodName)
    • toString

      public String toString()
      Overrides:
      toString in class Object