You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Andrew Robinson <an...@gmail.com> on 2006/05/25 23:47:24 UTC

Re: Help with t:dataTable t:selectBooleanCheckBox

You may want to try the control from Jenia. It is made to handle radio
and check boxes in a data table.

http://www.jenia.org/

Look under the dataTools "family"

You can then have something like:
XHTML:
<t:dataTable var="item" value="#{bean.items}">
  <t:column>
    <jdt:multipleRowsSelector selectionList="#{bean.selectedItems}" />
  </t:column>
</t:dataTable>

Java:
@Name("bean")
public class ExampleBean
{
  private List<Item> items = new ArrayList<Item>();
  private List<Item> selectedItems = new ArrayList<Item>();

  public List<Item> getItems() { return items; }
  public List<Item> getSelectedItems() { return selectedItems; }
  public void setSelectedItems(List<Item> selectedItems)
  { this.selectedItems = selectedItems; }
}


On 5/25/06, Vinicius Carvalho <vi...@synos.com.br> wrote:
>
>
>
> Hello there! We have a team developing a system using JSF in my company. I'm
> not a JSF person (I'm involved with Tapestry, but please I'm not here to
> compare, judge or anything, just seeking help)
>
>  So the team came to me because they're facing a problem.
>
>  We have a master-detail form, where we list the items using a dataTable and
> we have basic Crud operations as commandLinks.
>  Our problem is, when the user selects items using the selectBooleanCheckBox
> and clicks on the remove button, when we retreive the bounded variable it
> does not has the objects with their boolean properties modified hence we can
> not change the original list.
>
>  I don't know anything about JSF, but I guess this is a simple problem our
> developers are facing, if someone care to help me out here:
>
>  <h:panelGrid columns="3">
>                                  <h:commandButton id="novo"
> action="#{manterEvento.novo}"
>
> image="resources/imagens/bt-novo.gif"
>
> onclick="location.href='manterConvite.jsf'"
> immediate="true"/>
>                                  <h:commandButton id="SalvarEnviar"
>
> image="resources/imagens/bt-salvar-enviar-convite.gif"
>
> action="#{manterEvento.salvarEnviarConvite}"
> onclick="submit();" />
>                                  <h:commandButton id="ApagarSelecionados"
>
> image="resources/imagens/bt-apagar-selecionados.gif"
>                                          action="#{manterEvento.excluir}"
> onclick="excluir('form');" immediate="true"/>
>                          </h:panelGrid>
>
>                          <t:dataTable id="listaEventos"
> value="#{manterEvento.listaEventos}"
>                                  binding="#{manterEvento.listaUIData}"
>                                  var="evento" rows="4" width="100%"
> headerClass="cabecalho-tabela"
>                                  footerClass="rodape-tabela">
>
>                                  <t:column>
>                                          <f:facet name="header">
>                                                  <t:selectBooleanCheckbox
> onclick="selecionarTodos(this, 'form')" />
>                                          </f:facet>
>                                          <t:selectBooleanCheckbox
> value="#{evento.selecionado}"/>
>                                  </t:column>
>
>  The problem happens when the user clicks on the "ApagarSelecionados"
> commandButton, our managed bean:
>
>  private EventoService eventoService;
>          private UsuarioService usuarioService;
>          private Evento evento;
>          private List listaEventos;
>          private UIData listaUIData;
>  //getters and setters
>  public String excluir() {
>                  List l = (List)listaUIData.getValue();
>                  eventoService.excluirEventos(l);
>                  return null;
>          }
>
>  problem is that the excluirEventos methods, checks each Evento and see if
> selecionado is set to true, case it is, the event is removed from database,
> but as I said, no value is being changed from the list.
>
>  Best Regards
>