Like what you see? Have a play with our trial version.

Error rendering macro 'rw-search'

null

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

The PanelCollection API uses several helper objects, that could be used for passing around options, validation or setting up dependencies. These are listed below:

 

GeneralPanelOptions


The GeneralPanelOptions class is used to define general UI rendering options at the Parameter Panel and Section levels. Methods of significance are listed below:

 

MethodsDescription

public void setSaveButton(boolean saveButton)

public void setSaveButtonOptions(Map<String, Object> opts)

public void setSaveText(String saveText)

Setting the setSaveButton option to true displays a save button in the panel or section. Display options may be set using setSaveButtonOptions. Available options are listed under type BUTTON in the section on Input Types. The text on the button can be customized using setSaveText.

public void setExpandable(boolean expandable)

public void setExpanded(boolean expandable)

These are used to make a section expandable and render it expanded.

public void setShowName(boolean showTitle)When this is set to true, the name of the panel or section is displayed at the top of the container.
public void setCssRules(Set<CssRule> cssRules)

This method is used to set custom CSS rules to style a section or panel and everything within its html container.

 

 


CssRule


This interface is used to define styling rules in various levels of the PanelCollection API. The levels which support it, accept a set of CssRule objects. Yellowfin has an implementation called CssRuleImpl, which defines a single CSS Rule, such as:

 

div.styleExampleCell {
  	border: none;
  	color: #666666;
}

 

Instances will have a selector and one or more of CSS declarations. If a selector isn’t defined, Yellowfin will autogenerate one.

The CssDeclaration interface describes a single declaration such as:

 

border: none;

 

Yellowfin has an implementation called CssDeclarationImpl which accepts a property and value.


Parameter inputField = new ParameterImpl();
inputField.setName("Example Param");
inputField.setProperty("PARAM_PROPERTY");
inputField.setInputType(InputType.TEXTBOX);
 
CssRule cssRule = new CssRuleImpl("input", false);
cssRule.addDeclaration(new CssDeclarationImpl("height", "21px"));
cssRule.addDeclaration(new CssDeclarationImpl("padding", "5px"));
cssRule.addDeclaration(new CssDeclarationImpl("font-size", "16px"));
cssRule.addDeclaration(new CssDeclarationImpl("resize", "none"));
cssRule.addDeclaration(new CssDeclarationImpl("color", "#666666"));
cssRule.addDeclaration(new CssDeclarationImpl("border", "1px solid #e4e4e4"));
Set<CssRule> cssRules = new HashSet<>();
cssRules.add(cssRule);
inputField.setCssRules(cssRules);

 

This created the following CSS rule:

input {
  	height: 21px;
	padding: 5px;
	font-size: 16px;
	resize: none;
  	color: #666666;
  	border: 1px solid #e4e4e4;
}

 

 


ListOptions

This class is used to define UI options for when a parameter is rendered as a list. For example, a TEXTBOX parameter could accept several text values, for which it will render a list of textboxes.


Refer to the javadoc for all available options.

 

 


ParameterValidation

This class is used to define basic UI validation rules. The most useful rule is to check if a Parameter value is empty. Other rules perform relational operations on numeric Parameters.


Refer to the javadoc for all available options.

 

 

 


ParameterDisplayRule

There might be a need to hide or show a Parameter based on user input. This can be done using instances of ParameterDisplayRule which lets you define those Parameters which a Parameter should be listening to, and specify values to make it appear or hide. See examples below.


Example 1

The below snipped is for showing TABLE_NAME when SOURCE is set to anything other than 0 or null.

Parameter p = new ParameterImpl();
p.setName("Table Name");
p.setProperty("TABLE_NAME");
p.InputType(InputType.SELECT);
p.addDisplayRule(new ParameterDisplayRule("AND", "SOURCE", new Object[] { null, 0 }, true, null));

 

This display rule would essentially create the following line of code:

 

if(SOURCE != null && SOURCE != 0) showParameter();

 

 

Example 2

To make TABLE_NAME show when SOURCE was null or 0, the negative boolean should be changed to false.

 

p.addDisplayRule(new ParameterDisplayRule("AND", "SOURCE", new Object[] { null, 0 }, false, null));

 

This would create something like this:

if(SOURCE == null || SOURCE == 0) showParameter();

 

These display rules can be applied to any level of the Panel Collection, even to hide an entire panel or section.


Constructors

The class provides overloaded constructors for convenience and setters for each property. The most descriptive constructor is:


public ParameterDisplayRule(String logic, String property, Object[] vals, boolean negative, PropertyLocation location)

 

Below is an explanation of its attributes:

  • logic is used to specify the operator when there are multiple “child” display rules within this instance of ParameterDisplayRule. Logic may be AND or OR. If there are three child rules and logic is AND, each rule will be evaluated individually and the results will be combined as :
    Rule1Result && Rule2Result && Rule3Result
    Logic will be ignored if there are no “child” display rules. If there are child rules, the “parent” will not be evaluated. It will be used only as a container for the child rules.

  • property specifies the “other” parameter to be inspected by this display rule. Every Parameter instance has an identifier for its value. For example, whatever the user types into a Text Input parameter may be referenced using the identifier  “SOURCE” if it is specified as its property.

  • vals is an array of values for comparison. Each value in the array is compared against the “other” parameter for equality. They are then combined using the OR operator.

  • negative inverts the result obtained after comparing vals against the “other” parameter.
    If vals = {null, 0}

    negativeresult
    trueproperty != null && property != 0
    falseproperty == null || property == 0
  • location is an instance of PropertyLocation and is used to determine where the “other” parameter is located. This is useful if there are parameters with the same property in multiple sections/panels. If this is null, it is assumed the property is in the same location as the parent of this ParameterDisplayRule.





  • No labels