Ana içeriğe geç
Version: 1.4.0

Actions

To perform an action when we click a button, or a dependency is activated, we need to define a button-action or a dependency-action. The format of these actions is the next one:

<button-action type="[action]" target="[action-target]" context="[action-context]" silent="[silent]" async="[async]"
server-action="[server-action]" target-action="[server-target-action]"/>

or

<dependency-action type="[action]" target="[action-target]" context="[action-context]" silent="[silent]" async="[async]"
server-action="[server-action]" target-action="[server-target-action]"/>

Action attributes

AttributeUseTypeDescriptionValues
typeRequiredStringAction to be launched.See client action list
targetOptionalStringTarget of the actionOption, message or component identifier, depending on the action type
contextOptionalStringContext where the target isView where the component is or screen context
server-actionOptionalStringServer action callSee server action list
target-actionOptionalStringTarget to call on the server
silentOptionalBooleanLaunch the action without showing the loading bar
asyncOptionalBooleanLaunch the action in the async stack
valueOptionalStringValue to set to the criterion in case action is "value" type

Client actions

Client actions are processes launched in the client-side of the web application (on the web browser). They are launched sequentially (unless defined as async). Depending on the action type, the target and context attributes may differ in meaning.

General

Actions retrieved by the application to execute a generic action. These actions does not need extra attributes and apply to all components on the screen.

General actions

ActionDescription
resetEmpty all criteria on the screen
restoreRestore to initial values all criteria on the screen
restore-targetRestore to target values all criteria on the screen
validateLaunch a validation on all criteria on the screen
printLaunch a screen print. Same as navigator print option
confirm-updated-dataLaunch a confirm dialog to warn the user that there are criteria with data in the screen, and may lost them when navigating to another screen
confirm-not-updated-dataLaunch a confirm dialog to warn the user that the criteria in the screen have not been updated
confirm-empty-dataLaunch a confirm dialog to warn the user that all the criteria in the screen are empty
resizeLaunch a screen resize (useful for screen size changes)
toggle-menuShow/Hide the menu
toggle-navbarShow/Hide the navigation bar
disable-dependenciesDisable the dependency system
enable-dependenciesEnable the dependency system
cancelClear the current stack
valueSet a value to a criterion
waitWait an amount of milliseconds defined on target attribute
close-windowTries to close the current browser window (sometimes it'll ask to the user)

Message

Actions that eventually can show a message to the user.

Message actions

ActionDescription
confirmLaunch a confirm dialog with the message defined on target attribute

Message attributes

AttributeUseTypeDescriptionValues
targetRequiredStringMessage identifier

Navigation actions are used to move from one screen to another.

ActionDescription
backGo to the previous screen. Same as navigator back button. Does not need target attribute.
forwardGo to the next screen. Same as navigator forward button. Does not need target attribute.
screenGo to a screen. Needs target attribute.
reloadReload current screen
logoutLog out and exit the private menu. Does not need target attribute.
AttributeUseTypeDescriptionValues
targetDepends on actionStringOption identifier
contextOptionalStringContext of the screen. If not defined, the context is the same as the launcher screen has.screen/public for public options, screen/home for private options

Component

Actions which works over components in the screen.

Component actions

ActionDescriptionWorks on
add-classAdd the css class/classes defined on target-action to the tag with the selector defined on targettag
remove-classRemove the css class/classes defined on target-action to the tag with the selector defined on targettag
resetEmpty a criterion valuecriteria, grid, chart
restoreRestore to initial values a criterioncriteria, grid, chart
start-loadSets a component as loadingcriteria, grid, chart
validateLaunch a validation on the criterion or criteria inside the target tagtag, criteria
dialogOpens a modal dialogdialog
closeCloses a dialogdialog
filterReload a gridgrid
add-rowAdd an empty row at the bottom of the gridgrid
add-row-topAdd an empty row at the top of the gridgrid
add-row-upAdd an empty row over the selected rowgrid
add-row-downAdd an empty row below the selected rowgrid
copy-rowCopy the selected row at the bottom of the gridgrid
copy-row-topCopy the selected row at the top of the gridgrid
copy-row-upCopy the selected row over the selected rowgrid
copy-row-downCopy the selected row below the selected rowgrid
delete-rowDelete the selected rowgrid
save-rowSave the selected rowgrid
check-one-selectedChecks if there is one row selectedgrid
check-some-selectedChecks if there is one or more rows selectedgrid
check-records-savedChecks if all records are stored (user is not editing a row)grid
check-records-generatedChecks if there is at least one row in the gridgrid
select-first-rowSelects the first row of the gridgrid
select-last-rowSelects the last row of the gridgrid
select-all-rowsSelect all rows of the gridgrid
unselect-all-rowsUnselect all rows of the gridgrid
validate-selected-rowLaunch a validation on the selected row of the gridgrid
change-themeChanges the theme to the value defined on the target criterioncriteria
change-languageChanges the language to the value defined on the target criterioncriteria
reload-languageReload the language searching for changescriteria
next-stepMove to the next step of the wizardwizard
prev-stepMove to the previous step of the wizardwizard
first-stepMove to the first step of the wizardwizard
last-stepMove to the last step of the wizardwizard
nth-stepMove to the nth step of the wizardwizard

Component attributes

AttributeUseTypeDescriptionValues
targetRequiredStringComponent or tag identifier
contextOptionalStringContext of the component. If not defined, the context is the same as the launcher component has.base for the menu container screen, report@home for the menu options

Server call

Server call actions

ActionDescription
serverLaunch a server call with screen parameters
server-printLaunch a server call with screen parameters and print information
server-downloadLaunch a server call with screen parameters to call an action which will download a file

Server call attributes

AttributeUseTypeDescriptionValues
targetOptionalStringComponent or message identifier for callback
contextOptionalStringContext of the component for callback. If not defined, the context is the same as the launcher component has.base for the menu container screen, report@home for the menu options
server-actionRequiredStringAction to launch on server.See server actions
target-actionRequiredStringTarget for the server actionQuery identifier or Maintain identifier

Server actions

ActionDescriptionValues
loginLog in into the applicationUser and password
logout
screenNavigate to a screentarget: Menu option identifier
dataGet data from the server. Fills the values list of the criteriontargetAction: Query identifier
valueGet a value from the server. Fills the selected list of the criterion. In suggests, this action also fills the values listtargetAction: Query identifier
update-modelGet values for some criteria. The query field alias must be the criterion id to match. Fills the selected list of the criteriatargetAction: Query identifier
update-model-no-cancelIt does exactly the same update-model action does, but without cancelling the action stack when the query returns a warning/errortargetAction: Query identifier
subscribeSubscribe to a query data retrieval. The subscription stores the component request and broadcasts data to the component addresstargetAction: Query identifier
maintainLaunch a maintain processtargetAction: Maintain target identifier
maintain-silentLaunch a maintain process without response messagetargetAction: Maintain target identifier
maintain-asyncLaunch a maintain process without any responsetargetAction: Maintain target identifier
validateLaunch a query, and if it returns a warning or an error, invalidates the launcher with a messagetargetAction: Query identifier
uniqueLaunch a query, and if it returns data, invalidates the launchertargetAction: Query identifier
controlLaunch a query, and if it doesn't finish OK, returns a messagetargetAction: Query identifier
control-cancelLaunch a query, and if it doesn't finish OK, returns a message and cancels the action queuetargetAction: Query identifier
control-confirmLaunch a query, and if it doesn't finish OK, returns a confirm messagetargetAction: Query identifier, target: Confirm message identifier
control-confirm-cancelLaunch a query, and if it finish OK, cancels the queue and if it finishes with an error, returns a confirm messagetargetAction: Query identifier, target: Confirm message identifier
control-confirm-messageLaunch a query, and if it doesn't finish OK, returns a confirm message with the query message outputtargetAction: Query identifier
control-empty-cancelLaunch a query, and if it does not return data, it shows a message and cancels the queuetargetAction: Query identifier, target: Message identifier
control-unique-cancelLaunch a query, and if it returns data, it shows a message and cancels the queuetargetAction: Query identifier, target: Message identifier
app-helpShows the automatically generated screen help based on screen attributestarget: Screen identifier (optional)
helpGet the application help book in the current language
get-file-maintainLaunch a maintain process and retrieve a file to download

Client actions from Java services

These kind of actions are used to execute client actions from java services in the server. They are useful to perform many actions on window's element with a single service. For example, fill criteria and grids at once, dynamically add columns to a grid, add or replace graphic series, etc.

General actions from java services

ActionDescriptionParameters
messageSend a message to the client (without target)type - Message type (ok, info, warning, error), title - Message title, message- Message description
target-messageSend a message to a client componenttype - Message type (ok, info, warning, error), title - Message title, message- Message description

message

// Client action list
ServiceData serviceData = new ServiceData();

// Message action
ClientAction messageAction = new ClientAction("message");
messageAction.addParameter("type", "warning");
messageAction.addParameter("title", title);
messageAction.addParameter("message", message);
serviceData.addClientAction(messageAction);

target-message

// Client action list
ServiceData serviceData = new ServiceData();

// Message action
ClientAction messageAction = new ClientAction("target-message");
messageAction.addParameter("type", "warning");
messageAction.addParameter("title", title);
messageAction.addParameter("message", message);

// Optional
ComponentAddress address = new ComponentAddress(applicationName, null, "report", null, "CriterionId", null, null);
messageAction.setAddress(address);

serviceData.addClientAction(messageAction);

Criteria actions from java services

ActionDescriptionParameters
selectFill a criterion selected valuesvalues - Datalist with criteria value
fillFill a criterion list of available valuesrows - rows of datalist (at least must have value and label fields)

select

ServiceData setCriteriaValue() {
// Variable initialization
ServiceData serviceData = new ServiceData();

// Create client action to fill criteria
ClientAction selectCrtTransactionIdAction = new ClientAction("select");

// Set target (Criteria ID to set value)
selectCrtTransactionIdAction.setTarget("transactionId");

// Add parameters to actions
selectCrtTransactionIdAction.addParameter("values", Arrays.asList("TR001"))

// Add actions to serviceData
serviceData.addClientAction(selectCrtTransactionIdAction);

return serviceData;
}

Grid actions from java services

ActionDescriptionParameters
fillFill a grid with datalistrows - rows of datalist
total - Number of total pages of datalist
page - Page of datalist
records - Records number of datalist
add-columnsAdd columns to structure gridcolumns - ArrayNode with column structure
replace-columnsReplace columns grid with other columns structurecolumns - ArrayNode with column structure
update-cellUpdate cell in grid. Used to update cellData with other value, style, icon, title ...values - ObjectNode with cell attributes
add-rowAdd a row at the bottom of the gridrow - row values (optional)
selectedRow - Selected row identifier (optional)
add-row-topAdd a row at the top of the gridrow - row values (optional)
selectedRow - Selected row identifier (optional)
add-row-upAdd a row over the selected rowrow - row values (optional)
selectedRow - Selected row identifier (optional)
add-row-downAdd a row below the selected rowrow - row values (optional)
selectedRow - Selected row identifier (optional)
copy-rowCopy the selected row at the bottom of the gridselectedRow - Selected row identifier (optional)
copy-row-topCopy the selected row at the top of the gridselectedRow - Selected row identifier (optional)
copy-row-upCopy the selected row over the selected rowselectedRow - Selected row identifier (optional)
copy-row-downCopy the selected row below the selected rowselectedRow - Selected row identifier (optional)
update-rowUpdate the selected row valuesrow - row values, rowId - id of row to be updated (if none given, selected one will be selected), style - CSS class to add to the row (optional)
delete-rowDelete the selected row

fill

ServiceData fillGrid() {
// Variable initialization
ServiceData serviceData = new ServiceData();

// Create client action to fill many criteria
ClientAction fillGrdAction = new ClientAction("fill");

// Set target (Grid ID to fill)
fillGrdAction.setTarget("GrdParameterEventLst");

// Build datalist
DataList grdParametersDatalist = new DataList();
for (LokiPair pair : lokiMessage.getParameters()) {
HashMap<String, CellData> parametersRow = new HashMap<String, CellData>();
parametersRow.put("id", new CellData(rowIndex));
parametersRow.put("ParNam", new CellData(pair.getVariable()));
parametersRow.put("ParVal", new CellData(pair.getValue()));
parametersRow.put("ParTyp", new CellData(pair.getType()));
grdParametersDatalist.getRows().add(parametersRow);
}

// Add parameters to action
fillGrdAction.addParameter("datalist", grdParametersDatalist);

return serviceData;
}

add-columns

ServiceData addColumnsToGrid() {
// Variable initialization
ServiceData serviceData = new ServiceData();

// Create client action to fill many criteria
ClientAction addColumnsAction = new ClientAction("add-columns");

// Build dynamic column structure
ArrayList<Column> columnList = new ArrayList<Column>();
Column columnName = new Column();
columnName.setName("Name");
columnName.setLabel("COLUMN_LABEL");
columnName.setCharLength("15");
columnName.setField("Name");
columnName.setAlign("Center");

// Add column to list
columnList.add(columnName);

// Build column structure
ArrayNode columns = ColumnUtil.buildColumnListStructure(columnList);

addColumnsAction.setTarget("GrdDivididendList");

// Add parameters to action
addColumnsAction.addParameter("columns", new CellData(columns));

// Add action to list
clientActionList.add(addColumnsAction);

return serviceData;
}

replace-columns

ServiceData replaceColumnsToGrid() {
// Variable initialization
ServiceData serviceData = new ServiceData();

// Create client action to fill many criteria
ClientAction replaceColumnsAction = new ClientAction("replace-columns");

// Build dynamic column structure
ArrayList<Column> columnList = new ArrayList<Column>();
Column columnName = new Column();
column.setName("Name");
column.setLabel("COLUMN_LABEL");
column.setCharLength("15");
column.setField("Name");
column.setAlign("Center");

Column columnType = new Column();
columnType.setName("Type");
columnType.setLabel("COLUMN_TYPE");
columnType.setCharLength("15");
columnType.setField("Type");
columnType.setAlign("Center");

// Add column to list
columnList.add(columnName );
columnList.add(columnType );

// Build column structure
ArrayNode columns = ColumnUtil.buildColumnListStructure(columnList);

replaceColumnsAction.setTarget("GrdDivididendList");

// Add parameters to action
replaceColumnsAction.addParameter("columns", new CellData(columns));

// Add action to list
clientActionList.add(replaceColumnsAction);

return serviceData;
}

update-cell

...
// Variable initialization
ServiceData serviceData = new ServiceData();

ClientAction updateCell = new ClientAction("update-cell");

// Set values
ObjectNode values = JsonNodeFactory.instance.objectNode();
values.put("value", value);
values.put("label", label);
values.put("style", "updated");

// Build address of cell
ComponentAddress address = new ComponentAddress(applicationName, null, "report", null, "GrdSwapLst", idRow, idColumn);
updateCell.setAddress(address);
updateCell.setAsync("true");
updateCell.setSilent("true");
updateCell.addParameter("data", new CellData(values));

// Add action to list
clientActionList.add(updateCell);

return serviceData;

Note: If you want to change only a value, only passing the value to the data parameter inside a CellData is necessary. If you want to change anything more, then there'll be necessary to generate a JSON object with the model you want to update. In this model you must include the value and label attributes.

Chart actions from java services

ActionDescriptionParameters
replace-chart-seriesReplace the series of one chartseries - ArrayNode with chart series
add-chart-seriesAdd one serie to chartseries - ArrayNode with chart serie
remove-chart-seriesRemove the series of one chartseries - ArrayNode with chart series

replace-chart-series

/**
* Test method to replace the series of chart
*
* @param userList (Dummy list for build name of series)
* @return
* @throws AWException
*/
public ServiceData replaceSeriesChart(List<String> userList) throws AWException {

// Init variables
ServiceData serviceData = new ServiceData();
List<ClientAction> clientActionList = serviceData.getClientActionList();
JsonNodeFactory factory = JsonNodeFactory.instance;
ArrayNode serieList = factory.arrayNode();

// Get month list for xAxis
List<String> months = builDummyMonthList();

// Add json data of series
for (String user : userList) {
// New serie
ChartSerie serie = new ChartSerie();
serie.setId(user);
serie.setName(user);

// Add data to serie
for (String month : months) {
ChartSeriePoint point = new ChartSeriePoint(factory.textNode(month), factory.numberNode(new Random().nextInt((10 - 0) + 1) + 0));
// Add point to serie [x,y]
serie.getData().add(point);
}
// Add serie
serieList.add(serie.toJson());
}

// Create action replace series of chart
ClientAction replaceSeriesAction = new ClientAction("replace-chart-series");
replaceSeriesAction.setTarget("ChrLinTst");
ArrayList<Parameter> parameterList = replaceSeriesAction.getParameterList();
parameterList.add(new Parameter("series", new CellData(serieList)));
// Add action to list
clientActionList.add(replaceSeriesAction);

return serviceData;
}

add-chart-series

/**
* Test method to add the series of chart
*
* @param userList (Dummy list for build name of series)
* @return
* @throws AWException
*/
public ServiceData addSeriesChart(List<String> userList) throws AWException {

// Init variables
ServiceData serviceData = new ServiceData();
List<ClientAction> clientActionList = serviceData.getClientActionList();
JsonNodeFactory jsonFactory = JsonNodeFactory.instance;
// Get month list for xAxis
List<String> months = builDummyMonthList();

// Create arrayNode of chart series
ArrayNode serieList = jsonFactory.arrayNode();

// Add json data of series
for (String user : userList) {
// New serie
ChartSerie serie = new ChartSerie();
serie.setId(user);
serie.setName(user);

// Add data to serie
for (String month : months) {
ChartSeriePoint point = new ChartSeriePoint(jsonFactory.textNode(month), jsonFactory.numberNode(new Random().nextInt((10 - 0) + 1) + 0));
// Add point to serie [x,y]
serie.getData().add(point);
}
// Add serie
serieList.add(serie.toJson());
}

// Create action add series of chart
ClientAction addSeriesAction = new ClientAction("add-chart-series");
addSeriesAction.setTarget("ChrLinTst");
ArrayList<Parameter> parameterList = addSeriesAction.getParameterList();
parameterList.add(new Parameter("series", new CellData(serieList)));
// Add action to list
clientActionList.add(addSeriesAction);

return serviceData;
}

remove-chart-series

/**
* Test method to remove the series of chart
*
* @param userList (Dummy list for build name of series)
* @return
* @throws AWException
*/
public ServiceData removeSeriesChart(List<String> userList) throws AWException {

// Init variables
ServiceData serviceData = new ServiceData();
List<ClientAction> clientActionList = serviceData.getClientActionList();
JsonNodeFactory jsonFactory = JsonNodeFactory.instance;

// Create arrayNode of chart series
ArrayNode series = jsonFactory.arrayNode();

// Add json data of series
for (String user : userList) {
ChartSerie serie = new ChartSerie();
serie.setId(user);
// Add serie
series.add(serie.toJson());
}

// Create action remove series of chart
ClientAction removeSeriesAction = new ClientAction("remove-chart-series");
removeSeriesAction.setTarget("ChrLinTst");
ArrayList<Parameter> parameterList = removeSeriesAction.getParameterList();
parameterList.add(new Parameter("series", new CellData(series)));
// Add action to list
clientActionList.add(removeSeriesAction);

return serviceData;
}

Actions stack

Actions are launched sequentially. They are stored in an actions stack, and when the current action has finished, the next one is launched.

There are some actions that can clean the actions stack, like the cancel client action. Other actions freeze the current stack and creates another stack in an upper level, like the dialog client action.

sync-stack

Async stack

When you launch an action with the async flag activated, it is launched on the async stack. It is executed asynchronously, and does not wait for any other action.

async-stack

Show the stack

If you want to see what the stacks are doing, you can add a delay to these actions and make them visible by typing the next keys within the application focus:

ALT + SHIFT + [number]

Where [number] is the number of seconds you want to delay every action (for example, 1);

To disable the action stack, just do the same thing delaying 0 seconds:

ALT + SHIFT + 0

Examples

Validation

Validate all criteria, launch a confirm message and after that, launch a maintain target to store the screen data:

<button-action type="validate" />
<button-action type="confirm" target="[target]" />
<button-action type="server" server-action="maintain" target-action="[maintain-target]" />

Go to the previous screen, warning the user that the screen data may be lost

<button-action type="confirm-updated-data" />
<button-action type="back" />

Download a file stored somewhere

TextView

Screen

<criteria label="PARAMETER_TEXT" id="TxtViw" variable="ButVal" component="text-view" style="col-xs-6 col-sm-3 col-lg-2" icon="download">
<dependency>
<dependency-element id="TxtViw"/>
<dependency-element id="TxtViw" event="click"/>
<dependency-action type="server-download" server-action="get-file-maintain" target-action="downloadFile"/>
</dependency>
...
</criteria>

Maintain.xml

<target name="downloadFile">
<serve service="downloadFile">
<variable id="fileName" type="STRING" name="TxtViw" />
</serve>
</target>

Service.xml

<service id="downloadFile">
<java classname="com.almis.awe.test.File" method="downloadFile">
<service-parameter type="STRING" name="fileName" />
</java>
</service>

Java service

/**
* Given a file identifier, download a file
*
* @param fileIdentifier
* @return ServiceData
* @throws AWException
*/
public ServiceData downloadFile(String fileIdentifier) throws AWException {
ServiceData serviceData = new ServiceData();
FileController fileController = new FileController();
FileData fileData = fileController.getFileData(fileIdentifier);

String path = fileData.getFilePath();
FileInputStream file = FileUtil.getFileStream(path);

// Set variables
fileData.setFileStream(file);
serviceData.setData(fileData);
return serviceData;
}