Deselecting a table row in PrimeFaces - java

I have a table like this:
<p:dataTable id="table" selectionMode="single">
...
<p:ajax event="rowSelect" listener="#{myBean.onRowSelect}" update="someStuff"/>
<p:ajax event="rowUnselect" listener="#{myBean.onRowUnselect}" update="otherStuff"/>
</p:dataTable>
Does anyone know how to trigger the rowUnselect event on the UI ?
Another thing, what are the possible values of the selectionMode attribute ? They don't seem to be in the documentation.
Thanks,

To trigger rowUnselect, once a row is selected, hold control key and click on the row again. That way the row gets unselected, and the ajax event is executed.
Possibles values for selectionMode attribute are "single" and "multiple".

Related

Not able to render the parent panel group component with <p:ajax>

I am using primefaces autocomplete in my application to suggest userIds to the User.Once user enters three characters into the Autocomplete textbox my UserIds list will be suggested to the user to Autocomplete. As soon as user selects userId from List, I am updating the User First and Last name in the Output Text in the following format John Doe(jd123) with a Delete button beside to this name. As shown in comments in the code first ajax request is perfectly working fine.But When I am trying to delete name that I am printing using <h:outputText/> I am getting an error which is
javax.faces.FacesException: Cannot find component with identifier
"items" referenced from "j_idt34:0:imgid".
My Code :
<h:outputLabel value="Select user" for="acMinLength" />
<p:autoComplete id="acMinLength"
minQueryLength="3"
value="#{autoCompleteBean.txt2}"
completeMethod="#{autoCompleteBean.complete}">
<p:ajax event="itemSelect"
listener="#{autoCompleteBean.handleSelect}"
update="items"/> // First Ajax request perfectly working fine
</p:autoComplete>
<h:outputLabel value="selectedUsers" for="acMinLength" />
<h:panelGroup id="items">
<ui:repeat value="#{autoCompleteBean.printId}" var="item">
<h:outputText value="#{item}"/>
<h:graphicImage name="delete.png" library="images" id="imgid">
<p:ajax event="click"
listener="#{autoCompleteBean.updateList}"
update="items"/> // This is where i am getting exception
</ui:repeat>
<h:panelGroup>
I know I can update the parent component with child Ajax request. But I don't know what I am doing wrong.
it should be safer to update the h:form component. I'm not sure you can update every h: component by id. If you open the resulting xhtml and try checking the actual id path of the children components, you will see that the don't include the ids of all of their parent's component. Some id's are skipped
However, you can try this
update=":#{p:component('items')}"
Hope it helps
After a rigorous search I tried the answer posted by andre here(Primefaces - Cannot find component with identifier outside the datatable) and hurray it's working.
like this
update="#([id$=items])"

primefaces p:message outside the components form

I'm using JSF 2.0 and Primefaces 3.2.
I'm using Facelets for templating, and I've built a 3-column layout:
Left column - mainContent column - Right column. Each column got it's own template xhtml file with ui:composition which I insert in a mainTemplate.
In the mainContent column I've got a info-button (p:commandButton):
<h:form id="mainForm">
<p:commandButton id="infoButton" value="Info" actionListener="#{faceletsAttachment.addInfo}"/>
</h:form>
But I want the info to show in the right column, with a
<h:form id="rightColumnForm">
<p:message for="infoButton">
</h:form>
This obviously does not work, because does not find the infoButton. Any idea how I can make this work? I tried
<p:message for="mainForm:infoButton">
too, but no cigar.
The reason I want to use a p:message is that I want the message to position itself on the y-position the infoButton has. If you got an alternative solution to how I can do this, I would also appreciate it.
If you are adding messages manually from server side you can do the following
<p:message id="myInfoButton" for="myInfoButton" />
and send messages from server to myInfoButton like this
FacesContext.getCurrentInstance.addMessage("myInfoButton ", new FacesMessage("My Message", "Some Text goes here..."));
also add :rightColumnForm id to update of the <p:commandButton id="infoButton"

Restore <p:selectOneMenu> item, while editing

How can I bring the <p:selectOneMenu item values back while editing.Now it just showing 'Select One', and users have to select the desired one (or already submitted)again. How can I bring that?
try to remove the first f:selectItem of yours
<f:selectItem itemLabel="#{employeeView.employeeDTO.trMode}" itemValue='#{employeeView.employeeDTO.transportMode}' />
the value attribute of the <p:selectOneMenu tag will hold the selected value...
and by the way , here are several examples of it : p:selectOneMenu

How to know which item is clicked in richfaces PickList

I am using richfaces 4.1.0M2 with JSF2.0 and I have a PickList and what I want is that when someone selects (mouse click) an item in the left list, some component in the form is updated based on what is clicked. I have managed to trigger an event in the bean whan some one clicks on an item. The code to achieve the trigger is
<rich:pickList showButtonsLabel="false" value="#{groupBean.pickListResult}"
listHeight="100" converter="#{groupBean.converter}">
<a4j:ajax event="click" render="userlist" limitRender="true" listener="#{groupBean.updateGroupMembers}"/>
<f:selectItems value="#{groupBean.leftPickList}" />
</rich:pickList>
But I am not able to get the value of SelectItem which was clicked. Any idea how I can do that. I read in the documentation that each item has three states associated with it in the PickList i.e common, selected, active. So is there a way to get these states in the bean. Any idea.
The selected value will be available in groupBean.pickListResult (on the server)
I Think you Should use onchange Event in <a:support>
ex: <a4j:ajax event="onchange" render="userlist" limitRender="true" />

Set bean property "onselect" rich:combobox

<rich:comboBox id="combo" width="100px"
value="#{bean.scenarioString}"
suggestionValues="#{bean.scenarios}">
</rich:comboBox>
<a4j:commandButton value="button" action="#{bean.function}"></a4j:commandButton>
When the button is clicked scenarioString is being setted to selected value. But I want to set the scenarioString when the user select the value from combobox. Is this possible ? also if I can call the function after the scenarioString setted. it will be very help full. I try to use a4j:support but sure I have no value to set... I don't know, will the scenarioString be setted when the form is submitted but I try to use combobox in a h:form and try to submit "onselect" but I could't do it.
Update: I realized that my rich:combobox is already in a h:form, the h:form is in a iu:composition template, that I am using it for the page that my combobox in it.
<a4j:support event="onselect" >
<f:setPropertyActionListener target="#{bean.scenarioString}}" value="..."/>
</a4j:support>
Techs:JSF 1.2 RichFaces 3.3.3

Categories

Resources