Change the selection state of the litstbox item when a user clicks on a button (ZK 3.6.4) - listbox

I'm working in a project with ZK 3.6.4. but I have a problem, I want to change the selection state of the litstbox item when a user clicks on a button inside the same listbox ( same listitem)., because I want to know the selectedItem. I was reading zk documentation and I can do it , but with Zk version 5.0.5+ (nonselectableTags). But I cannot change for this version for project rules. So, there are a way to emulate this behavior with 3.6.4? or what kind of advices can you give me to do this? I really appreciate your help.
Here the code that I have.
<listbox
id="listDocAcads" mold="paging" pageSize="2"
model="#{win$composer.academicCollections}"
selectedItem="#{controller.docEntAcad}" >
<listhead>
<listheader
width="30%" label="Name" />
<listheader
width="15%" label="amount" />
<listheader
width="15%" label=" delivered?" />
<listheader
width="20%" label="Importance" />
<listheader
width="20%" label="Document" />
</listhead>
<listitem
self="#{each='docAcad'}" value="docAcad"
style="border:none;">
<listcell
label="#{docAcad.colleByProcess.oDocument.name}" />
<listcell
label="#{docAcad.colleByProcess.amount}" />
<listcell>
<spinner
width="60%" value="#{docAcad.amount}" />
</listcell>
<listcell
label="#{docAcad.colleByProcess.oImportance.name}" />
<listcell ><button id="btnUploadDocument" label="Upload"/> </listcell>
</listitem>
</listbox>

if you want to ignore button and input's u can do this.
nonselectableTags="button, input".
<listbox nonselectableTags="button, input">
<listitem><listcell><textbox/></listcell></listitem>
<listitem><listcell><button label="button"/></listcell></listitem>
<listitem><listcell><h:input xmlns:h="native"/></listcell></listitem>
<listitem><listcell><datebox/></listcell></listitem>
</listbox>
the values to nonselectableTags should be HTML tags separated by comma.
Hope this helps!

Related

pass method through ui:include to custom component

I have 3 files:
main.xhtml
<ui:include src="included.xhtml">
<ui:param name="bean" value="#{invoices}" />
<ui:param name="method" value="initExchange" />
</ui:include>
included.xhtml
<s:compositeComponent bean="#{bean}" beanMethod="#{method}"
buttonActionListener="#{bean[method]()}" />
compositeComponent.xhtml
<cc:interface>
<cc:attribute name="bean" />
<cc:attribute name="beanMethod" />
<cc:attribute name="buttonActionListener" method-signature="void f()" />
</cc:interface>
<cc:implementation>
<h:outputText value="#{cc.attrs.bean}" />
<h:outputText value="#{cc.attrs.beanMethod}" />
<p:commandButton actionListener="#{cc.attrs.buttonActionListener}" />
h:outputTexts are OK. But clicking on button gives exception:
Target Unreachable, identifier 'bean' resolved to null
How to pass the method to button's actionListener?
It works when actionListener in composite component is written as bean[method] like in included.xhtml:
<p:commandButton actionListener="#{cc.attrs.bean[cc.attrs.beanMethod]}" />
So generally passing method attributes through multiple stages should always be done by separate bean and method rather then one attribute with 'method-signature'.

Multiple conditions on TFS field

I need to set a TFS field as required based on two conditions. For example i want to set the field state as required if
Field "IsValid" value is not true
Field "Test Type" value is "Analysis"
Is it possible to set multiple conditions in TFS?
Even if it sounds too late, here's a tip that worked for me. It's a little tedious so I'll try to be clear.
Here is my context :
First I'm working with TFS 2018 RTM (16.122.27102.1) but i don't think it's important in that case.
I added a new field : an "end user description" on User Stories or BUGs to generate a change log based on a simple query.
I wanted this HTML Field to be mandatory only when
the Work Item is "Closed"
the reason is "Work finished"
the activity is "Development"
a new boolean field "Ignore for change log" is not True
Workaround :
I created a new field : "Custom.EndUserDescriptionMandatory" (Integer).
The order is important.
The idea is that when a Field that plays on the condition is changed, that new field is set to 1.
After that when the value does not respond to the required condition, that new field is set to 0.
Here is the XML for the rules :
<FIELD name="Mandatory user description" refname="Custom.EndUserDescriptionMandatory" type="Integer">
<DEFAULT from="value" value="0" />
<WHENCHANGED field="Custom.ChangeLogIgnore">
<COPY from="value" value="1" />
</WHENCHANGED>
<WHENCHANGED field="Custom.EndUserDescription">
<COPY from="value" value="1" />
</WHENCHANGED>
<WHENCHANGED field="System.Reason">
<COPY from="value" value="1" />
</WHENCHANGED>
<WHENCHANGED field="Microsoft.VSTS.Common.Activity">
<COPY from="value" value="1" />
</WHENCHANGED>
<WHENCHANGED field="System.State">
<COPY from="value" value="1" />
</WHENCHANGED>
<WHENNOT value="Closed" field="System.State">
<COPY from="value" value="0" />
</WHENNOT>
<WHENNOT value="Work finished" field="System.Reason">
<COPY from="value" value="0" />
</WHENNOT>
<WHEN value="true" field="Custom.ChangeLogIgnore">
<COPY from="value" value="0" />
</WHEN>
<WHENNOT value="" field="Custom.EndUserDescription">
<COPY from="value" value="0" />
</WHENNOT>
<WHENNOT value="Development" field="Microsoft.VSTS.Common.Activity">
<COPY from="value" value="0" />
</WHENNOT>
<HELPTEXT>(Internal use) allows to know whether Custom.EndUserDescription is mandatory or not</HELPTEXT>
</FIELD>
Finally I added a rule to the Workflow :
<STATE value="Closed">
<FIELDS>
<FIELD refname="Custom.EndUserDescription">
<WHENNOT value="0" field="Custom.EndUserDescriptionMandatory">
<REQUIRED />
</WHENNOT>
</FIELD>
</FIELDS>
</STATE>
I hope that will help.
In simple terms: It's not supported now.
Here has been a featured request in Voice of VS. You can also vote for it.
Allow nested when, whennot, whenchanged, and whennotchanged in TFS
work item definitions
https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/5760933-allow-nested-when-whennot-whenchanged-and-whenn

JSF: Update and add new request params

I have a page with the following params:
<f:metadata>
<f:event type="preRenderView" listener="#{busquedaBean.init}" />
<f:viewParam name="k" value="#{busquedaBean.keyword}" />
<f:viewParam name="categoryId" value="#{busquedaBean.categoryId}" />
<f:viewParam name="minprice" value="#{busquedaBean.minPrice}" />
<f:viewParam name="maxprice" value="#{busquedaBean.maxPrice}" />
</f:metadata>
All of them are optional. I need to do 2 things, which I wasn't able to do so far:
1) Add new params (keeping the previous params). This is what I tried for adding price params:
<h:outputText value="Precio diario" />
<o:form includeRequestParams="true">
<h:outputText value="min: " />
<p:inputText id="min" value="#{busquedaBean.minPrice}" />
<h:outputText value="max: " />
<p:inputText id="max" value="#{busquedaBean.maxPrice}" />
<p:commandButton icon="ui-icon-search" ajax="false">
<f:param name="minprice" value="#{busquedaBean.minPrice}" />
<f:param name="maxprice" value="#{busquedaBean.maxPrice}" />
</p:commandButton>
</o:form>
This basically works but the problem is that the URL is not updated. if the params in the URL were ?minprice=10&maxprice=200 and I update those values, the url remains the same. if these params were not included in the url, they won't be added and the filter won't work.
2) Updating the value of a param:
When categoryId is not empty, I want to show a button that will clear this param. This is what I tried:
<p:button outcome="/busqueda" includeViewParams="true" >
<f:param name="categoryId=" value="" />
</p:button>
But this button makes a GET to this URL: /busqueda/?categoryId=%3D&categoryId=1
The categoryId param appears twice. How can I just update the existing param?
I'm using MyFaces 2.1.14, Tomcat 7, Primefaces 4.0, Omnifaces
Thanks!
I was looking at this in the wrong way. includeViewParams=true will make the request include all the params declared in f:metadata with the current values. if such value is null, then the parameter is not included.
So.. to add price params:
<h:form >
<h:outputText value="$ " />
<p:inputText id="min" value="#{busquedaBean.minPrice}"/>
<h:outputText value=" a $ " />
<p:inputText id="max" value="#{busquedaBean.maxPrice}"/>
<p:commandButton icon="ui-icon-search" ajax="false" action="/busqueda?faces-redirect=true&includeViewParams=true" />
</h:form>
And to remove a param:
<p:commandButton action="#{busquedaBean.removeCategory}" ajax="false" icon="ui-icon-close" />
In the backing bean:
public String removeCategory() {
categoryId = null;
return "/busqueda?faces-redirect=true&includeViewParams=true";
}

Show dialog when the input data is validated <p:confirmDialog> [duplicate]

This question already has an answer here:
How to display dialog only on complete of a successful form submit
(1 answer)
Closed 6 years ago.
For my school project I have to realize a mini website where I use primefaces framework. In a form I want after pressing the Save button two things:
1 - Validate the data entered. that's why I put
<p:message for="date" /> and <p:message for="zone" />
As the values ​​are not correct, the dialog box should not be displayed.
2 - When all data is correct, and I click Save, I want to display my dialog box.
Now I can not. Can you help me? I use version 4 primefaces.
<h:form>
<p:panel id="panel" header="Create" style="margin-bottom:10px;border-color:blueviolet" >
<p:messages id="messages" />
<h:panelGrid columns="3">
<h:outputLabel for="date" value="Date : *" />
<p:calendar locale="fr" id="date" value="#{newBusinessCtrl.exercice.debut}" required="true" label="date" showButtonPanel="true"/>
<p:message for="date" />
<h:outputLabel for="zone" value="Zone Monétaire: *" />
<p:selectOneMenu id="zone" value="#{newBusinessCtrl.exercice.zoneChoice}" >
<f:selectItem itemLabel="Choice " itemValue="" />
<f:selectItems value="#{newBusinessCtrl.exercice.zones}" var="azone"
itemLabel="#{azone}" itemValue="#{azone}" >
</f:selectItems>
<p:message for="zone" />
</p:selectOneMenu>
<p:message for="zone" />
</h:panelGrid>
</p:panel>
<p:commandButton update="panel" value="Save" icon="ui-icon-check" style="color:blueviolet" onclick="choice.show()"/>
<p:confirmDialog message="Would you like to create accounts automatically ?"
header="Account creation" severity="alert"
widgetVar="choice" appendTo="#(body)">
<p:button outcome="personalizeAccount" value="Personalize" icon="ui-icon-star" />
<p:button outcome="autoAccount" value="Continue" icon="ui-icon-star" />
</p:confirmDialog>
Just show the dialog in Backing Bean like this:
Page:
<p:commandButton update="panel" value="Save"
icon="ui-icon-check"
style="color:blueviolet"
action="#{newBusinessCtrl.showDlg('choice')}"/>
Backing Bean:
public void showDlg(String dlgName){
RequestContext.getCurrentInstance().execute(dlgName+".show()");
}
Once the validation failed, the action won't execute and thus the dialog will not show.
If validation hasn't failed. PrimeFaces puts a global args object in the JavaScript scope which in turn has a boolean validationFailed property. You can check it before showing the dialog So you can use it this way:
<p:commandButton value="save" oncomplete="if (args && !args.validationFailed) saveDialog.show()"/>

JSF "rendered" - strange behavior

I can't explaine this well - it's need to see:
Video screencast
Please explain me what happens?
next code work and return true or false but when I put this to rendered="" this not work.
#{!empty detailsBean.goods.pictures}
rendered="true" rendered="false" rendered="#{true}" - work
<p:commandButton id="btn_details" value="#{msg.btn_details}" oncomplete="PF('dlg-detailed').show()" update=":dlg-detailed-id">
<f:setPropertyActionListener target="#{detailsBean.goods}" value="#{goods}" />
<f:param name="id" value="#{goods.id}"/>
</p:commandButton>
Dialog - where I try render text with condition.
<p:dialog id="dlg-detailed-id" widgetVar="dlg-detailed" header="#{msg.btn_details}" dynamic="true" modal="true" draggable="false" width="800" height="600">
<h:outputText value="Some Text For Rendering" rendered="#{!empty detailsBean.goods.pictures}" />
</p:dialog>
Mojarra 2.1.7-jbossorg-1
JBoss AS 7.1.1
I apologize for my mistakes in English
in this case, solution is: add < h:form> tag and then rendered="#{!empty detailsBean.goods.pictures}" work
<h:form id="form-detailed" >
<p:dialog id="dlg-detailed-id" widgetVar="dlg-detailed" header="#{msg.btn_details}" dynamic="true" modal="true" draggable="false" width="800" height="600">
<h:outputText value="Some Text For Rendering" rendered="#{!empty detailsBean.goods.pictures}" />
</p:dialog>
</h:form>

Resources