Hi Volker,

just one more question. I would like to call a method in a
person-object to add an empty person in the children-list like this:

MethodBinding MBactionListenerAddPerson = app.createMethodBinding("#{"
+ var + ".addEmptyChild}", new Class[]{ActionEvent.class});

The problem is, that the person-object, on which this method gets
called is not the same as the person which is displayed in the view.
The two person-object have different object-ids. I assume that this is
because the object gets serialized and restored with a new object-id.
Do you have an idea for this problem? If this is the wrong way to add
an empty child, I would store the personId of the parent-person in the
backing bean and travel over the person-tree and add the child on the
right person.

Best regards,
Rudi


On 4/23/07, Rudi Steiner <[EMAIL PROTECTED]> wrote:
Hi Volker,

this is exactly what i wanted, and it works. Wonderful!

Thank you,
Rudi

On 4/18/07, Volker Weber <[EMAIL PROTECTED]> wrote:
> Hi Rudi,
>
> now i understand what you want.
> your _getPersonTable() is recursive invoked, this must be considered
> at component creation.
>
> are you realy sure you want this?
>
> if so you need at least the following:
>
> a managedBean with a getter to fetch the outher list of person,
> each person object has a same named getter to fetch the sublist.
>
> following is your code a bit modifyed, something like this may work.
>
>
> Regards,
>     Volker
>
>
>  <h:form>
>      <h:dataTable binding="#{TableBean.personTable}" />
>   </h:form>
>
> //  The TableBean:
>
>
>   public HtmlDataTable getPersonTable() {
>
>                  return _getPersonTable("TableBean.persons", "person");
>          }
>
>   private HtmlDataTable _getPersonTable(String value, String var) {
>
>     FacesContext context = FacesContext.getCurrentInstance();
>     Application app = context.getApplication();
>
>     HtmlDataTable result = new HtmlDataTable();
>     result.setVar(var);
>     result.setValueBinding("value", app.createValueBinding("#{" + value + 
"}"));
>     result.setValueBinding("rendered",
> app.createValueBinding("#{!empty " + value + "}"));
>
>     ValueBinding VBfirstName = app.createValueBinding("#{" + var +
> ".firstname}");
>     ValueBinding VBsurName = app.createValueBinding("#{" + var + ".surname}");
>     ValueBinding VBbirthDate = app.createValueBinding("#{" + var +
> ".birthdate}");
>     ValueBinding VBtmpId = app.createValueBinding("#{" + var + ".tmpId}");
>     ValueBinding VBchildren = app.createValueBinding("#{" + var + 
".children}");
>
>
>     ValueBinding VBpropTmpIdToDelete =
>         app.createValueBinding("#{TableBean.tmpIdToDelete}");
>
>
>     //MethodBinding MBdeleteListener =
>     app.createMethodBinding("#{TableBean.deleteListener}", new
>         Class[]{ActionEvent.class});
>     //MethodBinding MBdeleteListener =
>     app.createMethodBinding("#{" + var + ".delete}", new
>         Class[]{ActionEvent.class});
>     MethodBinding MBdeleteListener =
>         app.createMethodBinding("#{TableBean.delete}", new
>             Class[]{ActionEvent.class});
>     MethodBinding MBaction =
> app.createMethodBinding("#{TableBean.action}", null);
>
>     UIOutput headerFirstName = new UIOutput();
>     headerFirstName.setValue("Vorname");
>
>     UIOutput headerSurName = new UIOutput();
>     headerSurName.setValue("Nachname");
>
>     UIOutput headerBirthDate = new UIOutput();
>     headerSurName.setValue("Geburtsdatum");
>
>     UIOutput outputFirstname = new UIOutput();
>     outputFirstname.setValueBinding("value", VBfirstName);
>
>     UIOutput outputSurname = new UIOutput();
>     outputSurname.setValueBinding("value", VBsurName);
>
>     UIOutput outputBirthDate = new UIOutput();
>     outputBirthDate.setValueBinding("value", VBbirthDate);
>
>     UIColumn columnFirstName = new UIColumn();
>     UIColumn columnSurName = new UIColumn();
>     UIColumn columnBirthDate = new UIColumn();
>     UIColumn columnDeleteButton = new UIColumn();
>     UIColumn columnChildren = new UIColumn();
>
>     columnFirstName.setHeader(headerFirstName);
>     columnFirstName.getChildren().add(outputFirstname);
>
>     columnSurName.setHeader(headerSurName);
>     columnSurName.getChildren().add(outputSurname);
>
>     columnBirthDate.setHeader(headerBirthDate);
>     columnBirthDate.getChildren().add(outputBirthDate);
>
>
>     //HtmlCommandButton deleteButton = new HtmlCommandButton();
>     HtmlCommandButton deleteButton = (HtmlCommandButton)
>         app.createComponent(HtmlCommandButton.COMPONENT_TYPE);
>
>
>     deleteButton.setImage("images/img_delete.gif");
>     deleteButton.setActionListener(MBdeleteListener);
>
>     UpdateActionListener ual = new UpdateActionListener();
>     ual.setPropertyBinding(VBpropTmpIdToDelete);
>     ual.setValueBinding(VBtmpId);
>     deleteButton.addActionListener(ual);
>     deleteButton.setAction(MBaction);
>
>     columnDeleteButton.getChildren().add(deleteButton);
>
>     // enable only one recursion
>     if (var.indexOf("_next") == -1) {
>       columnChildren.getChildren().add(_getPersonTable(var +
> ".persons", var + "_next"));
>     }
>
>
>     result.getChildren().add(columnFirstName);
>     result.getChildren().add(columnSurName);
>     result.getChildren().add(columnBirthDate);
>     result.getChildren().add(columnDeleteButton);
>     result.getChildren().add(columnChildren);
>
>     return result;
>   }
>

Reply via email to