Gente tenho o seguinte template velocity
#foreach ($ComponentJPanel in $arrayJPanel)e o meu código java está assim
#end
for (int i = 0; i < arrayJPanel.size(); i++) {
haveComponentJButton = false;
haveComponentJLabel = false;
haveComponentJTextField = false;
arrayJButton = new Stack<Object>();
arrayJTextField = new Stack<Object>();
arrayJLabel = new Stack<Object>();
ComponentJPanel c = (ComponentJPanel) arrayJPanel.get(i);
Stack<Object> arrayChildrenJPanel = c.getChildrenComponents();
for (int j = 0; j < arrayChildrenJPanel.size(); j++) {
if (arrayChildrenJPanel.get(j) instanceof ComponentJLabel) {
arrayJLabel.add(arrayChildrenJPanel.get(j));
haveComponentJLabel = true;
} else if (arrayChildrenJPanel.get(j) instanceof ComponentJTextField) {
arrayJTextField.add(arrayChildrenJPanel.get(j));
haveComponentJTextField = true;
} else if (arrayChildrenJPanel.get(j) instanceof ComponentJButton) {
arrayJButton.add(arrayChildrenJPanel.get(j));
haveComponentJButton = true;
}
}
context.put("componentJButton", haveComponentJButton);
context.put("componentJLabel", haveComponentJLabel);
context.put("componentJTextField", haveComponentJTextField);
context.put("arrayJPanel", arrayJPanel);
context.put("arrayJLabel", arrayJLabel);
context.put("arrayJTextField", arrayJTextField);
context.put("arrayJButton", arrayJButton);
}
Minha saida fica assim
porém não é isso que espero de saída, quero que no meu template sejam impressos os label, butons e textfields se existir esses componentes no meu panel, mas mesmo setando para true qdo o panel tem esses componentes ele nao imprime na minha saida, alguém sabe o que pode ser ?
acho que nao posso mudar um valor depois de passar ele no contexto, por este motivo as variaveis que indicam se o panel tem ou nao componentes ficam sempre false, mas nao tenho certeza se é isso.
alguém sabe como posso solucionar este problema ?
obrigada,
Marci