Velocity

0 respostas
M

Gente tenho o seguinte template velocity

#foreach ($ComponentJPanel in $arrayJPanel)
Teste $!{componentJButton}

#if ($componentJButton)

#foreach ($ComponentJButton in $arrayJButton)

#end
#end

#if ($componentJLabel)
#foreach ($ComponentJLabel in $arrayJLabel)
style= "position: absolute;font-family: $!{ComponentJLabel.getFontFamily()};
font-size: $!{ComponentJLabel.getFontSize()};
font-weight: bold;
width: $!{ComponentJLabel.getSizeWidth()};
height: $!{ComponentJLabel.getSizeHeight()};
left: $!{ComponentJLabel.getPositionLeft()};
top: $!{ComponentJLabel.getPositionTop()};"> $!{ComponentJLabel.getText()}

#end
#end

#if ($componentJTextField)
#foreach ($ComponentJTextField in $arrayJTextField)
style= "position: absolute;
font-family: $!{ComponentJTextField.getFontFamily()};
font-size: $!{ComponentJTextField.getFontSize()};
width: $!{ComponentJTextField.getSizeWidth()};
height: $!{ComponentJTextField.getSizeHeight()};
left: $!{ComponentJTextField.getPositionLeft()};
top: $!{ComponentJTextField.getPositionTop()};">
#end
#end


#end

e o meu código java está assim
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



Teste false






Teste false






Teste false






Teste false






Teste false



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

Criado 25 de setembro de 2008
Respostas 0
Participantes 1