Sorts the objects on the placeholder with the name placeholderName in the order of the result of the sortedByFormula. The formula has the same form as the List.sortedBy(sortedByFormula) formula in the formula language.
sortPlaceholderObjects(String placeholderName, String sortedByFormula) | |||
---|---|---|---|
Argument | String | placeholderName | The name of the placeholder of the component. |
String | sortedByFormula | A valid formula, which returns a sortedBy formula expression | |
Return value | |||
Exception | Throws a PlaceholderNotExistingException, if no placeholder with the specified name exists. Throws an EvaluationException, if an invalid formula is specified. |
import org.foederal.util.ui.messages.UserMessageCollector;
import com.mind8.mechatronic.skill.api.PlaceholderNotExistingException;
import com.mind8.expressionparser.EvaluationException;
placeholderName = "SchematicPages";
logText1 = "Script error: Cannot sort objects of the given placeholder due to a formula error: ";
logText2 = "Script error: A placeholder named 'SchematicPages' does not exist!";
listBefore = component.getPlaceholderObjects(placeholderName);
try
{
component.sortPlaceholderObjects(placeholderName," x | x.name");
}
catch (EvaluationException ex)
{
UserMessageCollector.addError(LIBRARY, self, null, "Script", logText1 + ex);
return;
}
catch (PlaceholderNotExistingException ex)
{
UserMessageCollector.addError(LIBRARY, self, null, "Script", logText2);
return;
}
listAfter = component.getPlaceholderObjects(placeholderName);
Result
listBefore = [<<M_SchematicPage>>,<<M_SchematicPage2>>]
listAfter = [<<M_SchematicPage2>>,<<M_SchematicPage>>]