voyent
strange behavior when using ice:selectBooleanCheckbox element in DataTable  XML
Forum Index -> Components
Author Message
spect

Joined: 12/Dec/2006 00:00:00
Messages: 5
Offline


Hello, all!

My problem is:
1)i use dataTable component and i attached list for showing some data
the first column in dataTable is
'<ice:selectBooleanCheckbox partialSubmit="true" value="#{iter.selected}" />'
and it attached to bool field "selected" in backend

2) there is functionality on my page for "select all checkboxes" in dataTable;
i create method called "selectAll()" on backend that realizing such functionality.
3) i checked that on backend bean all objects in list have "selected" field setting in true, but on page it remains false.
3.1) when i refresh page by self all checkboxes are settings in true

3.2)i add some code in selectAll method that changes other data in list (for example for ice:ouputText )and it works fine;
all changes are happens without page refresh.

it seems to me that partial submit don't work for ice:selectBooleanCheckbox that involved into dataTable element, because when i put it on page (not into table) partial submit works fine


Thanks for any ideas and sorry for my English.

zark

Joined: 09/Jun/2006 00:00:00
Messages: 90
Offline


hi spect

see this post, maybe can help you

http://www.icefaces.org/JForum/posts/list/3393.page


Good luck,
zark.
Andreh

Joined: 11/Dec/2006 00:00:00
Messages: 33
Offline


Hi,

I've followed your instructions and worked normally to me...
when I click the "selectAll" the dataTable work as expected, turning all the checkboxes to true.

This is some part of my code... let me know if You didn't make it to work.

Code:
		<ice:dataTable id="Table" value="#{myTable.list}" var="item">
 			<ice:column>
 				<f:facet name="header">
 					<ice:outputText value="Selects" />
 				</f:facet>
 				<ice:selectBooleanCheckbox value="#{item.selected}" partialSubmit="true" />
 					
 			</ice:column>
 			<ice:column>
 				<f:facet name="header">
 					<ice:outputText value="Nome" />
 				</f:facet>
 				<ice:outputText value="#{item.name}" />
 			</ice:column>
 		</ice:dataTable>
 	
 		<ice:commandButton value="SelectAll" actionListener="#{myTable.selectAll}" />
zark

Joined: 09/Jun/2006 00:00:00
Messages: 90
Offline


hi Andreh

use action method instead actionListener in the button if you want the page refresh it self.


<ice:commandButton value="SelectAll" action="#{myTable.selectAll}" />

and selectAll method in the BB is somethink like this:

Code:
 public String selectAll(){
 
 ..... your code
 
 return null;
 
 }
 


Good luck,
zark.
Andreh

Joined: 11/Dec/2006 00:00:00
Messages: 33
Offline


Hi zark,

Why use action instead of actionListener? is some good practice?
because my page works as expected using the actionListener...

I don't need to refresh the page itself, since the datatable renders it alone and modifies the values on the datatable.

Thanks!

zark

Joined: 09/Jun/2006 00:00:00
Messages: 90
Offline


hi Andreh

both method are a good practice, but each one has a specific use

action method refresh your page because it is part of the JSF navigation cycle. so, when you return null in an action method you are saying to JSF that after execute the method do a request to the current page(.iface,.jspx,etc...)

if you return something like "successful" the JSF search "successful" in your navigations case of your navigation rules of the current page configured in faces-config.xml

Code:
  <navigation-rule>
         <from-view-id>/currentPage.iface</from-view-id>
         <navigation-case>
             <from-outcome>successful</from-outcome>
             <to-view-id>/otherPage.iface</to-view-id>
             <redirect/>
         </navigation-case>
     </navigation-rule>
 


actionListener no refresh your page beacuse it is not part or the JSF navigation cycle. this method just execute his proccess and nothing request is trigged after his execution, actionListener is commonly used to validate code becose it is executed first that action method.

so see this .pdf can be useful
http://developers.sun.com/prodtech/javatools/jscreator/learning/bookshelf/pearson/corejsf/navigation.pdf

good luck,
zark
spect

Joined: 12/Dec/2006 00:00:00
Messages: 5
Offline


Hi, Andreh and zark! Thanks for your replies.

Andrew, the solution with "action" works correctly. But it still doesn't work with ice:selectBooleanCheckbox because this component has not "action" attribute.

zark, i think that it is not a good idea to create a copy of array when i want to select all checkboxes because it influences on performance and memory expenses.
zark

Joined: 09/Jun/2006 00:00:00
Messages: 90
Offline


hi spect

yes, i think that you are right about performance, this is a rapid solution
I'll search a better way to do that.


thanks,
zark
dcasanom

Joined: 07/Jan/2009 00:00:00
Messages: 2
Offline


Hi Spect
I created a simple solution that it works fine to me. Look this code, I think you wont need any major explanation. The point was to force the refresh using two selectBooleanCheckbox to draw his value. Look this code:

Code:
 <ice:column>
 	<f:facet name="header">
 		<ice:selectBooleanCheckbox value="#{myBean.selectedAll}" valueChangeListener="#{myBean.selectAll}">			 				
 	</ice:selectBooleanCheckbox>								
 	</f:facet>
 <ice:selectBooleanCheckbox value="#{iter.selected}" rendered="#{myBean.selectedAll}"></ice:selectBooleanCheckbox>
 <ice:selectBooleanCheckbox value="#{iter.selected}" rendered="#{!myBean.selectedAll}"></ice:selectBooleanCheckbox>
 </ice:column>
 

 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team