I am not sure how to use a zk Hbox Array. I am trying to create an array of ZK Hbox components and use it within a for block.
void createRow(Component container, final Node fieldNode, FieldCreator [] fieldDescription) {
final Vbox fieldsRows = new Vbox();
final Hbox fieldsRow = new Hbox();
final Hbox[] fieldBox;
int i=0;
for (FieldCreator fieldDesc : fieldDescription) {
fieldBox[i] = new Hbox();
fieldDesc.createField(fieldNode, fieldBox[i]);
i++;
}
fieldsRow.appendChild(fieldBox[]);
Button removeFieldButton = new Button(Messages.getString("MXFC_removeFieldButton")); //$NON-NLS-1$
fieldsRow.appendChild(removeFieldButton);
fieldsRows.appendChild(fieldsRow);
removeFieldButton.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
fieldNode.getParentNode().removeChild(fieldNode);
fieldBox[].setParent(null);
}
});
container.appendChild(fieldsRows);
}
The code above is incorrect. The compiler throws the error: “Syntax error on token “[“, Expression expected after this token.” on lines :
fieldsRow.appendChild(fieldBox[]);
fieldBox[].setParent(null);
How do I fix this?
Thanks,
Sony
Sony,
There are a few syntax errors in your java code.
To fix these problems we have to understand what you want to achieve in this piece of code. Based on my guess, you should
initialize fieldBox.
iterate through columns as you append/detach children of the row.