what meaning of self and each in zk framework - zk

My project have some code below as this. The last time people who use this framework have left this company. Please some one explain below code to me. What is the meaning of self and #each.
I don't know below listcell #item.areaNo the prefix item is from self="#{each='item' } or value="#{item }. And I really don't know what self="#{each='item' } means.
<listitem self="#{each='item' }" value="#{item }"
forward="onDoubleClick=onDoSelectItem,onClick=onDoChkDelete">
<listcell>
<fixedmodecheckbox label="${labels.delete}" />
</listcell>
<listcell label="#{item.areaNo}" />
<listcell label="#{item.formattedLocationNo}" />
<listcell label="#{item.storerCode.storerCode}" />
<listcell label="#{item.itemCode.itemCode}" />
<listcell label="#{item.itemCode.itemName }" />
<listcell label="#{item.stratedgyValue_2 }" />
<listcell label="#{item.palletNo }" />
<listcell label="#{item.itemCode.packCode.packCode }" />
<listcell label="#{item.stockCaseQty }" />
<listcell label="#{item.stockPieceQty }" />
<listcell label="#{item.allocationCaseQty }" />
<listcell label="#{item.allocationPieceQty }" />
</listitem>

Your code is using the "old databinding" syntax for rendering collections of objects.
It's still mentioned in the ZK 5 Developer's Reference, page 139 (available from the archive section). Even though deprecated since at least 6 or 7 years it's still part of ZK to support legacy code as in your case.
What it does (and I am also guessing a bit since this appears rarely in old code) is:
each is the current object of the collection, which is given a name item, so that it's accessible in binding expressions inside this repeated component self.
value="#{item}" will then simply call listitem.setValue(item) so that your listitem, remembers the object it's associated with.
I agree the syntax is weird and I assume that's why this has been deprecated and superseded by the new binding annotation syntax since ZK 6 or 6.5 (you can see a similar example at the bottom of this current documentation page).
However upgrading is not a drop-in replacement and requires quite some refactoring of your java code. That's why this kind of code keeps sticking around.

Related

How to Add additional columns to links page to ExternalLink types

How to add columns to ExternalLink on the "Links" page on Azure DevOps Workitem ?
Answered : Not Possible see answer below
Pull Request is not like Code Review Request, it's not a work item
type, we cannot see it from the exported process template. So, I don't
think we can customize the columns like the common work item types. –
Andy Li-MSFT
after going through the following links
link1
link2
and trying the workaround discussed here
I have failed to add more columns to links of the type externallink
i have added the following code as described:
<Page Label="Links" LayoutMode="FirstColumnWide">
<Section>
<Group Label="links">
<Control Type="LinksControl" Name="links">
<LinksControlOptions>
<LinkFilters>
<ExternalLinkFilter Type="Build" />
<ExternalLinkFilter Type="Integrated in build" />
<ExternalLinkFilter Type="Pull Request" />
<ExternalLinkFilter Type="Branch" />
<ExternalLinkFilter Type="Fixed in Commit" />
<ExternalLinkFilter Type="Fixed in Changeset" />
<ExternalLinkFilter Type="Source Code File" />
<ExternalLinkFilter Type="Found in build" />
<ExternalLinkFilter Type="GitHub Pull Request" />
<ExternalLinkFilter Type="GitHub Commit" />
</LinkFilters>
<Columns>
<Column Name="System.State" />
<Column Name="System.ChangedDate" />
<Column Name="System.PullRequest.IsFork" />
</Columns>
</LinksControlOptions>
</Control>
</Group>
</Section>
</Page>
But the results still show only the original columns.
The problem is that the field/column you added (<Column Name="System.PullRequest.IsFork" />) is not a valid work item filed/column. The workaround is only available for work item types due to the columns depend on work item fields.
You need to add a valid work item field/column here. We can get all the available work item fields by calling the Get Work Item REST API with parameter $expand=Fields added in the URL from a specific work item.
GET https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?$expand=Fields&api-version=4.1
For example, the following screenshots shows all the available fields for my Task work item. (It depends on how you defined the fields, if you defined a custom field, you can also see it from the response body.):
After that, we can add the columns (System.CreatedBy and Microsoft.VSTS.Common.Priority for example in this sample)
Then check the behavior in a Task work item:
Please note that, Pull Requests is not a work item type. We cannot get valid work item fields by calling the Pull Requests REST API. In this case, I don't think we can customize the columns like the common work item types.

Usage of Float and Integer in DynaActionForm properties and retrieving them with struts-html.tld tags

I have a DynaActionForm element in my struts-config.xml like:
<form-bean name="myActionForm" type="org.apache.struts.action.DynaActionForm">
<!-- Control Params -->
<form-property name="action" type="java.lang.String" />
<form-property name="list" type="java.lang.String" initial="master_document_list.data"/>
<!-- Business params -->
<form-property name="code" type="java.lang.String"/>
<form-property name="name" type="java.lang.String"/>
<form-property name="description" type="java.lang.String"/>
<form-property name="sequenceNumber" type="java.lang.Float"/>
</form-bean>
And the jsp page where I am trying to use it:
<!-- struts-html.tld imported with prefix html -->
<html:form>
<table>
<tr>
<td>Sequence No.</td>
<td><html:text property="sequenceNumber" maxlength="15" style="width:75%"/></td>
</tr>
<table>
</html:form>
but when i do this I am getting a JspException saying "No getter method for property sequenceNumber. I am quite sure that the name is correct. Is it the type that is not getting accepted then? I thought the DynaActionForm allowed types are all major java types including the Thread-Safe Wrappers (e.g. Float, Integer, Short, Long, etc.).
N.B. I am using struts1
After digging apache documentation, i figured out that
<html:text> tag has got the following settings:
name= Name of the form bean
property= Name of the property associated to the form-property tag for the bean above
Althernatively, using ${myBean.map.myProp} will point me to the right direction.
Thanks all,

field help text on form

Each share task form has fields. Some of them use icon to provide help text. For example, bpm:workflowPriority, get it. I need to remove this one.
I found, that сode below generates icons, but i cant understand, where the field.help process is runned. How i can hide icons for fields?
<#macro renderFieldHelp field>
<#if field.help?? && field.help?length > 0>
<span class="help-icon">
<img id="${fieldHtmlId}-help-icon" src="${url.context}/res/components/form/images/help.png" title="${msg("form.field.help")}" tabindex="0"/>
</span>
<div class="help-text" id="${fieldHtmlId}-help"><#if field.helpEncodeHtml>${field.help?html}<#else>${stringUtils.stripUnsafeHTML(field.help)}</#if></div>
</#if>
</#macro>
Help icon shows-up by-default when you have a constrain on your field. For example priority is defined as
<!-- Priority for the workflow as a whole -->
<property name="bpm:workflowPriority">
<type>d:int</type>
<default>2</default>
<constraints>
<constraint ref="bpm:allowedPriority" />
</constraints>
</property>
<constraint name="bpm:allowedPriority" type="LIST">
<parameter name="allowedValues">
<list>
<value>1</value>
<value>2</value>
<value>3</value>
</list>
</parameter>
</constraint>
I think help icon is a good idea if you have some constrain on your filed and want your user to select correct values.
You have following options:
If you don't need constraints , remove it from your model. You can override bpm:xxxxxx constraints by extending base model
You can look at BPMEngine code and change the template which generate help icon
Help icon is generated with class "help-icon" like :
span class="help-icon"
SO you can override form.css and hide this span. Something like this will work:
.form-container .help-icon {
visibility: hidden;
}
But this will remove all help icons from all the share forms, unless you change form divs and add some intelligence in your css selector.
Hope this helps.

How to re-render a RichFaces component after a4j link is invoked

Hoping someone can help me with a slight hurdle I've come up against in regards to re-rendering of RichFaces components after an a4j link/button has performed it's action. A simplified version of my problem is as follows:
I have 2 output components displaying a text value which are rendered based on some value in my manager class:
<h:outputText id="on" value="ON" rendered="#{manager.isOn}" />
<h:outputText id="off" value="OFF" rendered="#{not manager.isOn}" />
I also have 2 a4j links that call some action and then re-render the above outputText components:
<a4j:commandLink ajaxSingle="true" value="Set On" action="#{manager.setOn(true)}" reRender="on,off" />
<a4j:commandLink ajaxSingle="true" value="Set Off" action="#{manager.setOn(false)}" reRender="on,off" />
What I would expect to happen is, when I click the 'Set On' button, the 'ON' outputText component would unhide, and the 'OFF outputText component would show. However, this does not happen.
Does anyone have the answer as to why this is so, and how I go about re-rendering these components after the a4j component action has completed?
Wrap the outputText components in an s:div and re-render that as follows:
<s:div id="myDiv">
<h:outputText id="on" value="ON" rendered="#{manager.isOn}" />
<h:outputText id="off" value="OFF" rendered="#{not manager.isOn}" />
</s:div>
<a4j:commandLink ajaxSingle="true" value="Set On"
action="#{manager.setOn(true)}" reRender="myDiv" />
<a4j:commandLink ajaxSingle="true" value="Set Off"
action="#{manager.setOn(false)}" reRender="myDiv" />
I agree with Gene but the best way I could find is to surround the content with
<a4j:outputpanel id="whatever_id" />
for example,
<a4j:outputpanel id="myDiv">
<h:outputText id="on" value="ON" rendered="#{manager.isOn}" />
<h:outputText id="off" value="OFF" rendered="#{not manager.isOn}" />
</a4j:outputpanel>
You rerender the parent. It doesn't have to be a Seam tag.
I suppose that your h:outputText elements on and off are not rendered at load time of the page.
RichFaces will not rerender these components later even if the value of rendered changed to true.

jBPM, concurrent execution and process variables

When a process in jBPM forks into concurrent paths, each of these paths gets their own copy of the process variables, so that they run isolated from each other.
But what happens when the paths join again ?
Obviously there could be conflicting updates.
Does the context revert back to the state before the fork?
Can I choose to copy individual variables from the separate tracks?
I think that you have to configure the Task Controllers of your tasks. In some cases it is enough to set the access attribute in a way that does not result in conflicts (e.g. read access to the first path and read,write access to the second path). If this is not the case then you can implement your own TaskControllerHandler and implement the method void submitTaskVariables(TaskInstance taskInstance, ContextInstance contextInstance, Token token) with your custom logic. Please see: Task Controllers.
I tried a little experiment:
<fork name="fork1" >
<transition to="right" />
<transition to="left" />
</fork>
<node name="left">
<event type="node-enter">
<script>
<expression >
left="left";
shared = left;
</expression>
<variable name='left' access='write' />
<variable name='shared' access='write' />
</script>
</event>
<transition to="join" />
</node>
<node name="right">
<event type="node-enter">
<script>
<expression >
right="right";
token.parent.processInstance.contextInstance.setVariable("fromRight", "woot!");
shared = right;
</expression>
<variable name='right' access='write' />
<variable name='shared' access='write' />
</script>
</event>
<transition to="join" />
</node>
<join name="join" >
<transition to="done"></transition>
</join>
<end-state name="done"/>
At the end I had access to three variables, shared, right and "fromRight" which was set by the script against the parent explicitly.
The shared variable took its value from the right fork, changes made on the left seemed to dissappear.
Note that the transitions aren't actually asynchronous for me, and the whole experiment will have run in one transaction, these factors may affect the outcome