myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Hedström <er...@peregrine.com>
Subject Re: [jira] Updated: (MYFACES-627) valueChangeListener not called for elements in HtmlDataTable
Date Fri, 28 Oct 2005 18:25:37 GMT
Can we get someone to take a look at this patch? Without it, all the
clientIds for editable fields in a table are the same for each row, when
using the Sun RI with the Tomahawk dataTable.

thanks!
Eric

On 26 Oct 2005 10:23, Senthil Chelladurai (JIRA) wrote:

>      [ http://issues.apache.org/jira/browse/MYFACES-627?page=all ]
> 
> Senthil Chelladurai updated MYFACES-627:
> ----------------------------------------
> 
>     Attachment: HtmlDataTableHack.patch
> 
> I have identified the bug and have a solution.
> 
> ----------------------Start  from SUN RI UIData----------------------------------------------------
>     public String getClientId(FacesContext context) {
> 
>         if (context == null) {
>             throw new NullPointerException();
>         }
> 	String baseClientId = super.getClientId(context);
>         if (rowIndex >= 0) {
>             return (baseClientId + NamingContainer.SEPARATOR_CHAR + rowIndex);
>         } else {
>             return (baseClientId);
>         }
> 
>     }
> -----------------------End SUN RI UIData------------------------------------------------------------
> -----------------------Start Myfaces UIData----------------------------------------------------------
>     public String getClientId(FacesContext context)
>     {
>         String clientId = super.getClientId(context);
>         int rowIndex = getRowIndex();
>         if (rowIndex == -1)
>         {
>             return clientId;
>         }
>         return clientId + "_" + rowIndex;
>     }
> -----------------------End Myfaces UIData------------------------------------------------------------
> 
> Carefully look at the above code fragment and you will notice that SUN RI uses a class
private variable rowIndex to check for current row and creates the clientId accordingly, whereas
Myfaces uses the method getRowIndex() method to get the current row number. 
> 
> Why is this a problem?
> Myfaces(tomahawk) has a class called HtmlDataTableHack which duplicates and overrides
most of the methods and field variables, so the rowIndex variable is not getting updated in
Sun RI UIData which uses field variable instead of the getRowIndex() method. This ends up
creating the same id for all rows so the Decode phase sees only one value and so updates only
the first value, this has a slightly different effect on command components where the action
is fired for all rows even though only a specific action was triggered.
> 
> Solution: the getClientId method should also be overridden in HtmlDataTableHack to solve
this problem.
> 
> I have attached the patch file with the fix.
> 
> Hope to see the fix incorporated.
> Senthil
> 
> 
>>valueChangeListener not called for elements in HtmlDataTable
>>------------------------------------------------------------
>>
>>         Key: MYFACES-627
>>         URL: http://issues.apache.org/jira/browse/MYFACES-627
>>     Project: MyFaces
>>        Type: Bug
>>  Components: Tomahawk
>>    Versions: 1.1.1
>> Environment: JSF RI 1.1.01
>>    Reporter: Keith Lynch
>>    Priority: Critical
>> Attachments: HtmlDataTableHack.patch
>>
>>The processValueChange method is never called in some cases and called only for the
first element in the list for others.
>>If the value of the first row inside the inputText component is changed then the valueChangeListener
is called. If the inputText component in any other row is changed the valueChangeListener
is not called. 
>>The valueChangeListener is never called for the selectBooleanCheckbox.
>>I have not tested with any other sub-components.
>>This is possibly an RI compatibility issue however I cannot test with the myfaces
impl as I am using components which are not compatible with it.
>>x:dataTable 	value="#{ilrTestsMgr.details.currentPageContent}" 
>>			  var="test"
>>			  rendered="true"
>>			  rowClasses="even-row,odd-row" 
>>			  styleClass="bluelist" 
>>			  width="100%">
>>  <h:column> 
>>     <f:facet name="header">
>>        <h:outputText value="#{bundle.generic_enabled}"/>
>>     </f:facet>
>>   <h:selectBooleanCheckbox value="#{test.enabled}"  valueChangeListener="#{ilrTestsMgr.details.processValueChange}"/>
>>  </h:column>
>>  <h:column>
>>    <f:facet name="header">  
>>      <h:outputText value="#{bundle.testcase_value}"/>
>>    </f:facet>  	    
>>    <h:inputText value="#{test.expected}" valueChangeListener="#{ilrTestsMgr.details.processValueChange}"/>
>>  </h:column>
>>  
>></x:dataTable>
> 
> 


Mime
View raw message