You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mapoitras <ma...@gmail.com> on 2007/07/04 15:44:06 UTC

Problem updating a column using datatable

I have a table that displays all rows as readonly.  If the user clicks on the
edit button on the side, then that column is no longer readonly and they can
update the value.  However when the instance gets back to the backing bean
the data for columns that were originaly readonly has not been updated.  Any
idea?  In the example below, only one column is read only at first.  When
they click on edit, I update the column but the new data never gets back to
the backing bean.  If I remove the readonly clause it works, however all the
rows are now editable.  We can only permit one row to be edited at a time
because of special validations that need to be done.

			
	<fieldset>		
		<legend>#{msgs.ddListOfDisabilitiesLbl}&#160;
				<h:commandButton onclick="if
(!#{disabilityDetail.authorizationMap['12']})
{alert('#{msgs.authNotAuthorized}'); return false;}" 
								action="#{disabilityDetail.addRowAction()}" 
								value="#{msgs.ddAddNewDisabilityTypeBtn}" 
								disabled="#{disabilityDetail.isSaveBtnDisabled}" /></legend>
		
		<h:dataTable value="#{disabilityList}" var="disability"
			styleClass="view" headerClass="viewHeader"
			rowClasses="viewRows" 
		
columnClasses="viewColDisabilityCrud,viewColDisabilityCrud,viewColDisabilityType,viewColDisabilityOccCnt">
			
			<h:column rendered="#{!disabilityDetail.isSaveBtnDisabled}">			 			
				<s:link id="removeDisabilityId"
action="#{disabilityDetail.removeRowAction()}" 
					rendered="#{!disabilityDetail.isCreatableRow and
!disabilityDetail.isEditableRow }">
					<h:graphicImage id="removeImageId" alt="Remove"
url="../images/delete.gif"
									onclick="if (!#{disabilityDetail.authorizationMap['12']})
{alert('#{msgs.authNotAuthorized}'); return false;}" /> 					
					<f:param name="instanceParamId" value="#{disability.id}"/>										
					<s:conversationPropagation type="join"/>
				</s:link>				
			</h:column>	
			<h:column>
				<h:outputText value="" rendered="#{disabilityDetail.isCreatableRow or
disabilityDetail.isEditableRow}"/>				 			
				<s:link id="editDisabilityId" action="#{disabilityDetail.editRowAction}" 
rendered="#{!disabilityDetail.isCreatableRow and
!disabilityDetail.isEditableRow}">
					<h:graphicImage id="editImageId" alt="Edit"
url="../images/editable.gif"
									onclick="if (!#{disabilityDetail.authorizationMap['12']})
{alert('#{msgs.authNotAuthorized}'); return false;}" /> 
					<f:param name="instanceParamId" value="#{disability.id}"/>					
					<s:conversationPropagation type="join"/>
				</s:link>			
			</h:column>	
			
			<h:column>				
				<f:facet name="header">#{msgs.ddTypeOfDisabilityTtlLbl}</f:facet>
					<h:selectOneMenu value="#{disability.disabilityTypeCode}"
converter="#{disabilityDetail.disabilityTypeCodePickList.converter}" >
						<f:selectItems
value="#{disabilityDetail.disabilityTypeCodePickList.pickListMap}"
/></h:selectOneMenu>
			</h:column>
			<h:column>
				<f:facet
name="header">#{msgs.ddNoOfOccupantsWithDisabilityTtlLbl}</f:facet>
	               	<h:inputText id="Occupants_Count"
value="#{disability.occupantsCount}" class="rightalign" size="5"
maxlength="5" readonly="#{!(disability.id == null or
(disabilityDetail.isEditableRow and disability.id ==
disabilityDetail.instanceParamId))}">
	               	</h:inputText><br/>
					<h:message for="Occupants_Count" styleClass="ahMessages"/>		
			</h:column>							 
		</h:dataTable>	

	</fieldset> 
-- 
View this message in context: http://www.nabble.com/Problem-updating-a-column-using-datatable-tf4024533.html#a11431233
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Problem updating a column using datatable

Posted by David Delbecq <de...@oma.be>.
Hello,

Check that

readonly="#{!(disability.id == null or
(disabilityDetail.isEditableRow and disability.id ==
disabilityDetail.instanceParamId))}"

is true, not only at render time, but also, after submission of new
value by user, at processValidation phase. If it's false at render time,
html edit box will be readonly. If it's false at processValidation time,
even if it was true at previous render, the submitted value will be
ignored by component.

regards,
David Delbecq
En l'instant précis du 04/07/07 15:44, mapoitras s'exprimait en ces termes:
> I have a table that displays all rows as readonly.  If the user clicks on the
> edit button on the side, then that column is no longer readonly and they can
> update the value.  However when the instance gets back to the backing bean
> the data for columns that were originaly readonly has not been updated.  Any
> idea?  In the example below, only one column is read only at first.  When
> they click on edit, I update the column but the new data never gets back to
> the backing bean.  If I remove the readonly clause it works, however all the
> rows are now editable.  We can only permit one row to be edited at a time
> because of special validations that need to be done.
>
> 			
> 	<fieldset>		
> 		<legend>#{msgs.ddListOfDisabilitiesLbl}&#160;
> 				<h:commandButton onclick="if
> (!#{disabilityDetail.authorizationMap['12']})
> {alert('#{msgs.authNotAuthorized}'); return false;}" 
> 								action="#{disabilityDetail.addRowAction()}" 
> 								value="#{msgs.ddAddNewDisabilityTypeBtn}" 
> 								disabled="#{disabilityDetail.isSaveBtnDisabled}" /></legend>
> 		
> 		<h:dataTable value="#{disabilityList}" var="disability"
> 			styleClass="view" headerClass="viewHeader"
> 			rowClasses="viewRows" 
> 		
> columnClasses="viewColDisabilityCrud,viewColDisabilityCrud,viewColDisabilityType,viewColDisabilityOccCnt">
> 			
> 			<h:column rendered="#{!disabilityDetail.isSaveBtnDisabled}">			 			
> 				<s:link id="removeDisabilityId"
> action="#{disabilityDetail.removeRowAction()}" 
> 					rendered="#{!disabilityDetail.isCreatableRow and
> !disabilityDetail.isEditableRow }">
> 					<h:graphicImage id="removeImageId" alt="Remove"
> url="../images/delete.gif"
> 									onclick="if (!#{disabilityDetail.authorizationMap['12']})
> {alert('#{msgs.authNotAuthorized}'); return false;}" /> 					
> 					<f:param name="instanceParamId" value="#{disability.id}"/>										
> 					<s:conversationPropagation type="join"/>
> 				</s:link>				
> 			</h:column>	
> 			<h:column>
> 				<h:outputText value="" rendered="#{disabilityDetail.isCreatableRow or
> disabilityDetail.isEditableRow}"/>				 			
> 				<s:link id="editDisabilityId" action="#{disabilityDetail.editRowAction}" 
> rendered="#{!disabilityDetail.isCreatableRow and
> !disabilityDetail.isEditableRow}">
> 					<h:graphicImage id="editImageId" alt="Edit"
> url="../images/editable.gif"
> 									onclick="if (!#{disabilityDetail.authorizationMap['12']})
> {alert('#{msgs.authNotAuthorized}'); return false;}" /> 
> 					<f:param name="instanceParamId" value="#{disability.id}"/>					
> 					<s:conversationPropagation type="join"/>
> 				</s:link>			
> 			</h:column>	
> 			
> 			<h:column>				
> 				<f:facet name="header">#{msgs.ddTypeOfDisabilityTtlLbl}</f:facet>
> 					<h:selectOneMenu value="#{disability.disabilityTypeCode}"
> converter="#{disabilityDetail.disabilityTypeCodePickList.converter}" >
> 						<f:selectItems
> value="#{disabilityDetail.disabilityTypeCodePickList.pickListMap}"
> /></h:selectOneMenu>
> 			</h:column>
> 			<h:column>
> 				<f:facet
> name="header">#{msgs.ddNoOfOccupantsWithDisabilityTtlLbl}</f:facet>
> 	               	<h:inputText id="Occupants_Count"
> value="#{disability.occupantsCount}" class="rightalign" size="5"
> maxlength="5" readonly="#{!(disability.id == null or
> (disabilityDetail.isEditableRow and disability.id ==
> disabilityDetail.instanceParamId))}">
> 	               	</h:inputText><br/>
> 					<h:message for="Occupants_Count" styleClass="ahMessages"/>		
> 			</h:column>							 
> 		</h:dataTable>	
>
> 	</fieldset> 
>