Issue: I am unable to rerender MenuItems in a MenuGroup of rich:contextMenu on selection of a row in a table.
Scenario: I have table of 5 colums and multiple rows. Mouse right click on a row should open contextMenu which has MenuGoup Items, this Group should display MenuItem of values of selected row of specific column values.
I am generating a ArrayList in backing bean and have coded like below. But this menuItemPanel is not rendering. And not showing any values.
<rich:contextMenu>
<rich:menuItem
value="View"
action="#{bakingBean.view}">
</rich:menuItem>
<rich:menuGroup value="Show All Column Values">
<a4j:outputPanel id="menuItemPanel">
<c:forEach items="#{bakingBean.items}" var="item">
<rich:menuItem value="#{item}"
action="#{backingBean.filter}">
<f:param name="filterVal" value="#{item}"/>
</rich:menuItem>
</c:forEach>
</a4j:outputPanel>
</rich:menuGroup>
Related
I have a primefaces dataTable which is both select-able (single selection) and has draggable rows. I also need to select a row via a button (apart from being able to select the row itself). My view code is:
<p:dataTable id="itemTable" widgetVar="itemTable"
var="item" draggableRows="true"
value="#{routesModelBean.itemList}" selectionMode="single"
selection="#{routesModelBean.selectedItem}"
rowKey="#{item.id}" rowIndexVar="rowId">
<p:column style="width:32px;text-align: center">
<p:commandButton icon="ui-icon-search"
onclick="PF('itemTable').unselectAllRows();PF('itemTable').selectRow(#{rowId},false);" type="button">
</p:commandButton>
</p:column>
The problem seems to be the "rowIndexVar". For example, if i have two items in my list and i swap them by dragging, then clicking the button of one item will result in selecting the other.
Edit: Primefaces version is 6.0
When reordering the rows you should update the table too. Use the following
<p:ajax event="rowReorder" listener="YOUR_LISTENER" update=":itemTable" />
I am working with PrimeFaces 5. The row selection is enabled and I want to embed a commandLink in one of the columns. When I click on the commandLink, I show a dialog, but I do not want the row to be selected. Is this possible (currently both events happen, the dialog is shown and the row is selected)?
<p:dataTable id="tableData" widgetVar="tableData" var="p"
value="#{bean.list}" ...
selection="#{bean.selectedItem}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{actionBean.onSelect}"
update="#form" onstart="PF('statusDialog').show();"
oncomplete="PF('statusDialog').hide();" />
<p:column headerText="Title" ...>
<p:commandLink id="clickableTitle" onstart="PF('statusDialog').show();"
oncomplete="PF('statusDialog').hide();PF('detailsDialog').show()">
<h:outputText value="#{p.title}" styleClass="link"/>
</p:commandLink>
</p:column>
I am using <p:autoComplete> in my webproject. When lots of data coming to the search box the position of list is from bottom to top instead of top to bottom and not all data is visible.
How can I fix it so that it shows the data from top to bottom?
You can use the scrollHeight attribute to define height of the items those are seen in list as follows
<p:autoComplete value="#{bean.text}" completeMethod="#{bean.complete}" scrollHeight = "150" />
Primefaces documentation will definitely help you regarding this
<p:autoComplete id="acOrden" value="#{serviciosMB.ordenSelect}"
completeMethod="#{serviciosMB.complete}"
var="mauto"
itemValue="#{mauto}"
itemLabel="#{mauto.consecutivoOrden}"
converter="ordenProduccionServiciolConverter" required="true">
<p:ajax event="itemSelect" listener="#{serviciosMB.renderPanelOrden}" update="panelOrden :form2:growl" />
<p:column>
#{mauto.codigoOrden}
</p:column>
</p:autoComplete>
see ajax listener
I have a simple p:dataTable which fires an AJAX event when selecting a row:
<p:dataTable var="c" value="#{myBean.dmCars}"
selection="#{myBean.car}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{myBean.select}"/>
<p:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{c.name}"/>
</p:column>
</p:dataTable>
This works fine, but I can only select a row once. I want to select the same row multiple times and the event listener of p:ajax invoked for each click.
Update I think it's because the row has somewhere the state selected. You see the selected row with a grey background in this example: http://www.primefaces.org/showcase/ui/datatableRowSelectionInstant.jsf
#Daniel and #MattHandy, thank you both for your support. I found a solution to this issue:
public void select()
{
// Do some stuff
car=null;
}
In the backing bean i set the value holder to null after I've processed the event.
I have a dataTable that when a user selects a row a number of fields are populated so they can see more detail. of that particular item. However, at the moment the page loads with the unpopulated panelgrid and populates on selecting of a row. How can I hide this panelgrid and get it to show once the row has been selected??
Thanks
Use the rendered attribute and let it evaluate true if anything has been selected.
E.g.
<h:panelGrid rendered="#{not empty bean.selectedRow}">
<h:outputText value="#{bean.selectedRow.foo}" />
<h:outputText value="#{bean.selectedRow.bar}" />
...
</h:panelGrid>