Richfaces 4.5 picklist having duplicates on right side - jsf

Environment:
Jboss 7.1.1.Final
JSF 2.2.6
Seam 2.3.1.Final
Richfaces 4.5.10.Final
Issue:
The rich:picklist populates the right hand side with duplicates during the second time load of a popup. Here are the steps to reproduce.
The popuppage with the rich:picklist is loaded by clicking on a link in a main page
The popup page loads with the rich:picklist populated with the right side and left side values
The values are added from left side of picklist to right side and the popup is saved.
Now when we reopen the popup the picklist has duplicate values on the right side
XHTML Snippet:
<rich:pickList id="AssignRole" value="#{staffResourceRolesTargetList}" sourceCaption="Roles" targetCaption="Assigned Roles" listHeight="120"
converter="#{org.jboss.seam.ui.EntityConverter}" orderable="false">
<f:selectItems value="#{staffResourceRolesSourceList}"
var="assignRoles" itemLabel="#{assignRoles.name}" />
<f:selectItems value="#{staffResourceRolesTargetList}"
var="assignedRoles" itemLabel="#{assignedRoles.name}" />
</rich:pickList>
Note:
I have overridden the hashcode and equals method in the entity used in the picklist
I had to use two f:selectItems list inorder for the right side to prepopulate
The source and target list are of the same entity collection
Please help me debug this. I have spent a lot of time and hope that someone can give me direction. Please let me know if you need more info.

Related

How to only update input of p:selectOneMenu, not the suggestion panel

I'm using primefaces 5.3 and i have a page which has p:selectOneMenu as below:
<p:selectOneMenu id="addressCountry" value="#{myBean.address.country}">
<f:selectItems value="#{myBean.countries}" var="country"
itemValue="#{country.code}" itemLabel="#{country.name}" />
</p:selectOneMenu>
This is a combobox that allow users to select their country. It show all countries around the world (250 countries) so it lead to performance problem.
My page have several tabView and each of them has several comboboxes like this, when i switch tab and update whole tabView, all those comboboxes will be renderred again and it increase payload a lot.
I know with SelectOneMenu, Primefaces divide it into two parts: the input and the panel to hold all selectable options. When i update this component by id (update=":#{p:component('addressCountry')}"), Primefaces will render both parts, even the panel just static contents and no need to be rendered again for every request.
I've try to update by css selector (just select the input) but it also not work.
Can we only update the input, exclude the panel when we need?
Anybody can help me?
Thanks alot

bootsfaces b:commandButton in ui:repeat not updating h:graphicImage

I'm using the 0.7 version of bootsfaces to create a simple page, which has something like the following:
<h:form id="some_form">
<ui:repeat id="some_elements" var="property" value="#{someBean.properties}">
<b:commandButton value="ShowProp" ajax="true" actionListener="#{someBean.showProperty(property)}" update=":some_form:some_elements:graphic"/>
<!-- This property is true -->
<ui:fragment rendered="#{someOtherBean.showGraphic}">
<h:graphicImage url="gen_image?id=#{property.id}" id="graphic"/>
</ui:fragment>
</ui:repeat>
</h:form>
Now, the idea is that on clicking the button, a property is updated and the image should be re-generated (in this case a jfreechart graph - but this is besides the point.) I tested this with primefaces commandButton and it works fine (the graph is redrawn..) However with bootsfaces commandButton, nothing happens once the ajax call completes (I can see the call on the server side, but the graph is not reloaded.) I think it's down to how it must reference the image in the repeated block, but now sure what is wrong - has anyone come across this?
(NOTE: reason I don't want to use primefaces is that it does not integrate well with bootstrap)
I've opened a bug on the project's bugtracker (https://github.com/TheCoder4eu/BootsFaces-OSP/issues/135).
Actually, why did you expect the update=":some_form:some_elements:graphic" to work in the first place? This expression is an id that doesn't exist. The id is some_form:some_elements:0:graphic. In other words: it contains the row number. PrimeFaces (and Mojarra and MyFaces) recognizes that the command button is part of a UIRepeat group and guesses the correct row number. But that's just a guess. Obviously a reasonable guess, because most of the time you want to update something that's in the vicinity of the command button.
The next version of BootsFaces is going to guess the correct row number, too :).

JSF rerender clears html code added onload

I add a checkbox in front of specific components like dropdowns on page load. When a particular dropdown on change reRenders the a4j:outputPanel which has the checkbox, the checkox disappears. Is it because of the view being created and then I have added the checkbox. OR the a4j:outputPanel is the cause. I cannot remove the panel. Can anyone please guide me?
P.S : If I dont reRender the a4j:outputPanel the checkbox remains. But I need to reRender the panel.
The reason it disappears is that as you said it is added using javascript. When you render an element using jsf + ajax the element is created from the response from server. As the server knows nothing about your onload code, it removes the element and recreates it with response from server.

JSF 2.0 and Primefaces integration for ajax update of center section

I have left, right and center panels in my xhtml page. Left panel contains menu item links and want to use them to refresh the center section through ajax.
I have seen quite a few links related to this but I am not sure on the final solution.
If this is not the preferred approach, please do guide on the same.
I am using managed beans which are sessionscoped and xhtml file uses following to do the dynamic call.
<p:menuitem value="Done" action="#{navBean.setPageName('done')}" update="centerPanel" immediate="TRUE" />
When I use primefaces 2.2.1, i am able to update the center panel on second click only from the menu in left panel.
When I use primefaces 3, the center section doesn't get updated.
The managed bean setter does get invoked in both cases.
Is it something to do with primefaces configuration or am I missing something?

JSF: Button/Link without form submit

In earlier projects I often used an s:button or s:link from Seam 2 when caceling something, because it wouldn't submit the form and thus no model updates occured.
Now I switched to WELD + Seam 3 and couldn't find it there anymore - am I just blind or do I have to use something else?
Geziefer
You can do it in plain JSF 2.0 by setting immediate attribute to true in the h:commandButton.
From the MyFaces wiki:
The immediate attribute can be used to achieve the following effects:
Allow a commandLink or commandButton to navigate the user to
another page without processing any data currently in input fields of
the current screen. In particular, this allows navigation to occur
even when there are currently validation errors. A "cancel" button
typically falls into this category.
Allow a commandLink or commandButton to trigger back-end logic
while ignoring validation for some of the fields on the screen. This
is a more general version of the item above.
Make one or more input components "high priority" for validation,
so that if any of these are invalid then validation is not performed
for any "low-priority" input components in the same page. This can
reduce the number of error messages shown.
I found a way to handle it by using the commandButton from RichFaces 4 and setting bypassUpdates to true:
<a4j:commandButton value="Cancel" action="#{myHandler.cancel}"
bypassUpdates="true" render="myTable" />
For me this solution is ok, since I'm allready using RichFaces 4 - but I'm still interested, how to solve this with standard JSF 2.0?

Resources