String labelVar = BUNDLE_VALUE;
String var = "#{" + varName + "." + NamingConstants.ATTRIBUTES + "['%s'].%s}";
columns = columns == 0 ? 2 : columns * 2;
HtmlPanelGrid panel = (HtmlPanelGrid) app.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
panel.setColumns(columns);
/*
* First find bar code attribute it should be added before
*/
for (AbstractAttribute attr : attributes) {
String valExp = null;
UIComponent cmp = null;
switch (attr.getDataType()) {
case STRING:
valExp = String.format(var,
attr.getName(),
NamingConstants.STRING_VALUE);
cmp = app.createComponent(InputText.COMPONENT_TYPE);
((InputText)cmp).setValueExpression(VALUE_NAME, getExpression(valExp));
break;
case NUMBER:
valExp = String.format(var, attr.getName(),
NamingConstants.NUMBER_VALUE);
cmp = app.createComponent(InputText.COMPONENT_TYPE);
((InputText)cmp).setValueExpression(VALUE_NAME, getExpression(valExp));
((InputText)cmp).setConverter(new NumberConverter());
break;
case DATE:
valExp = String.format(var, attr.getName(),
NamingConstants.DATE_VALUE);
cmp = app.createComponent(Calendar.COMPONENT_TYPE);
((Calendar)cmp).setValueExpression(VALUE_NAME, getExpression(valExp));
break;
}
HtmlOutputLabel label = (HtmlOutputLabel) app.createComponent(HtmlOutputLabel.COMPONENT_TYPE);
label.setValueExpression(VALUE_NAME, getExpression(String.format(labelVar, attr.getName())));
panel.getChildren().add(label);
panel.getChildren().add(cmp);
}
return panel;
}