3

I'm using Primefaces 3.5 5th December 2012 SNAPSHOT, with Mojarra 2.1.14 and Tomcat 7.0.33.

When using the in-cell editing mode (not in-row) for POJO objects with a model/entity class that are represented in a h:selectOneMenu, with 'click' as the celleditevent value, whenever you click on an object and then 'click away' by clicking on some other object, the previous object is displaying its value instead of its label. This is only 'cosmetic' as when you reload the page, it will show the label value.

<p:dataTable id="insurancepolicyTable" var="insurancepolicy" widgetVar="insurancepolicyList" value="#{insurancepolicybean.objectList}" paginator="true" rows="15" paginatorPosition="bottom" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" currentPageReportTemplate="#{text['table.insurancepolicy.filter.count']}" rowsPerPageTemplate="15,25,50,100" emptyMessage="#{text['table.insurancepolicy.filter.notfound']}" filteredValue="#{insurancepolicybean.filteredObject}" editable="true" editMode="cell" cellEditEvent="click" draggableColumns="true" rowKey="#{insurancepolicy.id}" > 


               <p:column id="branchColumn" headerText="#{text['label.branch']}" sortBy="#{insurancepolicy.branch.name}" filterBy="#{insurancepolicy.branch.name}" filterMatchMode="contains">  
                <p:cellEditor>  
                    <f:facet name="output">  
                        <h:outputText value="#{insurancepolicy.branch.name}" />  
                    </f:facet> 
                    <f:facet name="input">  
                        <div  class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all">
                            <p:selectOneMenu id="branchselectinsurancepolicylist" value="#{insurancepolicy.branch}" styleClass="customSelect" converter="omnifaces.SelectItemsIndexConverter">                      
                                <f:selectItems value="#{insurancepolicybean.branchList}" var="branch" itemLabel="#{branch.name}" itemValue="#{branch}" />                    
                            </p:selectOneMenu>    
                        </div>
                    </f:facet> 
                </p:cellEditor>    
            </p:column>   
            <p:ajax event="cellEdit" listener="#{insurancepolicybean.onEdit}" update="@form" />
            <pe:resetInput event="cellEdit" for="@form" />

        </p:dataTable>  
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
javaMS
  • 401
  • 4
  • 9
  • 20
  • Are you implying that it works as expected when not using `SelectItemsIndexConverter`? – BalusC Dec 05 '12 at 12:14
  • No. It works fine for selectonemenus with simple String arrays without converters. – javaMS Dec 05 '12 at 16:45
  • When it worked, did you use the same string value as both item value and item label? This look much like a PrimeFaces bug wherein the option value is redisplayed after edit instead of option label. This is then not caused by the OmniFaces converter. – BalusC Dec 05 '12 at 17:37
  • I used the same value/label pair. I guess that's why it seemed to "work". – javaMS Dec 06 '12 at 04:42

1 Answers1

5

I can reproduce it. It's a bug in PrimeFaces. This problem is not related to the converter. The problem is just caused by PrimeFaces-specific JavaScript code which incorrectly redisplays the value of the selected option instead of the label of the selected option after "unedit".

This is more easily to be reproduced as follows:

<p:selectOneMenu value="#{insurancepolicy.branchAsString}">                      
    <f:selectItems value="#{insurancepolicybean.branchMap}" />
</p:selectOneMenu>

with

private Map<String, String> branchMap;

@PostConstruct
public void init() {
    branchMap = new LinkedHashMap<String, String>();
    branchMap.put("branch label 1", "branch value 1");
    branchMap.put("branch label 2", "branch value 2");
    branchMap.put("branch label 3", "branch value 3");
}

I recommend to report it to PrimeFaces guys.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks, I've reported it under http://code.google.com/p/primefaces/issues/detail?id=4971. Appreciate your efforts. – javaMS Dec 06 '12 at 04:43
  • based on the comment I saw in the Primefaces issue tracker I doubt that the Primefaces team want to solve this issue. Do you have any idea which Javascript needs to be fixed? I tried to look into it but didn't understand which code is causing this. – javaMS Dec 09 '12 at 04:56