views:

1235

answers:

2

Hi all,

I am having a tough time trying to find a solution to the following design related to h:dataTable.

I have certain number of rows predisplayed. The first column is only checkboxes. The rest of the columns are disabled by default. On selecting a checkbox the elements in the corresponding rows get enabled. On submit of the for the values in the enabled row have to be validated on the server side. I am able to validate for invalid inputs but am not finding a method to use required="true" conditionally. Or any other method. Could anyone please help me on this.

Thanks Barun

+1  A: 

I'm guessing you have a bean that looks something like this...

public class SomeBean {
   boolean selected = false;
   String someProperty;

   ...
}

If you have a controller for those beans your markup would look something like this...

<h:dataTable value="#{SomeController.someBeans}" var="someBean">
   <h:column> 
      <f:facet name="header">Select</f:facet>
      <h:selectBooleanCheckbox value="#{someBean.selected}"/>
   </h:column>
   <h:column> 
      <f:facet name="header">Input</f:facet>
      <h:inputText value="#{someBean.someproperty}" required="#{someBean.selected}"/>
   </h:column>
</h:dataTable>
Drew
A: 

you should have a method like

public boolean isSelected(){

return selected;

}

Levent
Having getters/setters for bean properties is indeed nothing more than obvious :)
BalusC
thx einstein but everbody is not a genius like you :)
Levent