Search code examples
htmlmergewickettextfielddataview

Error When iterate over with a DataView component that is dynamically visible


doubt the wicket ... I'm using a DataView and is being released the following error:

"... Expected close tag is' <td wicket: id =" lblRowspan "> 'Possible attempt to embed component (s)' <input type =" text "placeholder =" Item "wicket: id =" txtNomeBem "class = "form-control" /> 'in the body of this component Which discards its body ... "

The situation is as follows in this DataView am using ROWSPAN to merge some cells, 100% works well if there is no type of component in the lines that I'm mixing, for example, if the lines that I'm using rowSpan write a sentence works. .. but when I insert the TextField component in the cell does not.

In the application I'm developing need to show a TextField so that the person enter some information, only it's always thrown the exception that pointed up.

here is my code: (html)

<tr wicket:id="dataGruposSelecionados">
    <td wicket:id="lblRowspan">
        <input type="text" placeholder="Item" wicket:id="txtNomeBem"
               class="form-control" />
    </td>
<tr/>

Here is my java

dataViewGruposSelecionados = new DataView<ItemBemDto>("dataGruposSelecionados", new Provider(listaDeGrupos)) {

            @Override
            protected void populateItem(Item<ItemBemDto> item) {    

    Label lblRowspan = new Label("lblRowspan",item.getModelObject().getNomeItemGrupo());
.
.
.
    int tamanho = listaBens.size();
    if(primeiroLoop)
    {                    
        lblRowspan.add(new AttributeAppender("rowspan", new Model<Integer>(tamanho), " "));
         primeiroLoop = false;
     }else{
         lblRowspan.setVisible(false);
     }
.
.
.
.
    item.add(lblRowspan);
    item.add(newTextFieldNomeItem(item));
  }
}

as I said, it works 100% if in place of the TextField I leave it blank or type something in HTML, the merge works ... but when I insert any component within the 'td' is thrown the exception ...


Solution

  • I found the answer :) . Instead of a label to control the 'rowspan' the Dataview I created a WebMarkupContainer receiving ROWSPAN ... well, below the HTML and java solution I found.

    <td wicket:id="containerRowspan">
        <div wicket:id="panelNomeGrupo">
            <input type="text" placeholder="Item" wicket:id="txtNomeBem" class="form-    control" />
        </div>
    </td>
    

    Code Java:

         WebMarkupContainer containerRowspan = new WebMarkupContainer("containerRowspan");
    
         int tamanho = listaComTodosBens.size();
    
         if(primeiroLoop || !item.getModelObject().getNomeItemGrupo().equalsIgnoreCase(nomeAnterior)){
               containerRowspan.add(new AttributeAppender("rowspan", new Model<Integer>(tamanho), " "));
              primeiroLoop = false;
            }else{
               containerRowspan.setVisible(false);
            }
    
         PanelNomeItem panel=new PanelNomeItem("panelNomeGrupo", item);
         panel.setVisible(mostrarPainel);
         containerRowspan.add(panel);
         item.add(containerRowspan);