Configuring Portlet Template Parameter State Properties

Portlet template parameters are added automatically as state properties to the view component’s STATE object. Therefore, you can provide additional configuration options for them in the STATE object. The example below sets the default value for the portlet template parameter color in its *MVCRenderCommand class:

Template template = (Template)renderRequest.getAttribute(
			WebKeys.TEMPLATE);
      
String color = "red";

template.put("color", color);

The configuration above has the implicit state property configuration shown below in the view’s component file (View.es.js for example):

   View.STATE {
     color: {
       value: 'red'
     }
   }

You can provide additional settings by configuring the state Property in the View component. The example below defines a setter function that transforms the color’s string to upper case before adding it to the STATE object:

function setColor(color) {
  return color.toUpperCase();
}

View.STATE = {
  color: {
    setter: 'setColor'      
  }
}

Now you know how to configure portlet template parameter state properties!

Understanding the State Object’s Architecture

Configuring Soy Portlet Template Parameters on the Client Side

« Understanding The State Object's ArchitectureConfiguring Soy Portlet Template Parameters on the Client Side »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0