i am newable to smartGWT. currently in our project need to show and hide checkbox/StaticItem based on certain contrains(that is when changing selectitem it will shown this fields).but my case not shown.these fields are added in a list and set a visibility to false.that dynamic form added to the canvas. after that based on condition it will show the fields. the code was supposed to form item as visible but not working here.
Canvas getFlags()
{
if(dff == null)
{
dff = new DynamicForm();
dff.setNumCols(4);
dff.setWrapItemTitles(false);
dff.setWidth(60);
dff.setPadding(10);
dff.setPageLeft(25);
int size = IPGui.flags.size();
fitem = new FormItem[size];
lform = new ArrayList<FormItem>();
for(int i=1;i<=size;i++)
{
String flgnme = IPGui.flags.get(i).getAttribute("ATTCCTD");
cbox= new CheckboxItem("ATTCCTD"+i);
cbox.setTitle(flgnme);
cbox.setLabelAsTitle(true);
cbox.setVisible(false);
st = new StaticTextItem("staticItem"+i);
st.setTitle("Disney");
st.setVisible(false);
lform.add(cbox);
lform.add(st);
}
dff.setFields(lform.toArray(fitem));
}
else
{
if(isValid)
{
for(FormItem item: dff.getFields())
{
System.err.println("Item--->"+item.getName());
if(item.getName().startsWith("ATTCCTD") || item.getName().startsWith("staticItem"))
{
item.setVisible(true);
dff.markForRedraw();
}
}
}
}
cv.addChild(dff);
return cv;
}
---------------------------------------------
calling this method:
VLayout vl3 = new VLayout();
vl3.setWidth100();
vl3.setMembers(getOrderForm(),getFlags());
setPane(vl3);
Note: Initally the form has to be null .so if part will work once form to loaded changing the selectitem am calling this getFlags() method. so condition it will go to the else part and statisfied all criteria but fields are invisble still.
Note: Size is 5.
Canvas getFlags()
{
if(dff == null)
{
dff = new DynamicForm();
dff.setNumCols(4);
dff.setWrapItemTitles(false);
dff.setWidth(60);
dff.setPadding(10);
dff.setPageLeft(25);
int size = IPGui.flags.size();
fitem = new FormItem[size];
lform = new ArrayList<FormItem>();
for(int i=1;i<=size;i++)
{
String flgnme = IPGui.flags.get(i).getAttribute("ATTCCTD");
cbox= new CheckboxItem("ATTCCTD"+i);
cbox.setTitle(flgnme);
cbox.setLabelAsTitle(true);
cbox.setVisible(false);
st = new StaticTextItem("staticItem"+i);
st.setTitle("Disney");
st.setVisible(false);
lform.add(cbox);
lform.add(st);
}
dff.setFields(lform.toArray(fitem));
}
else
{
if(isValid)
{
for(FormItem item: dff.getFields())
{
System.err.println("Item--->"+item.getName());
if(item.getName().startsWith("ATTCCTD") || item.getName().startsWith("staticItem"))
{
item.setVisible(true);
dff.markForRedraw();
}
}
}
}
cv.addChild(dff);
return cv;
}
---------------------------------------------
calling this method:
VLayout vl3 = new VLayout();
vl3.setWidth100();
vl3.setMembers(getOrderForm(),getFlags());
setPane(vl3);
Note: Initally the form has to be null .so if part will work once form to loaded changing the selectitem am calling this getFlags() method. so condition it will go to the else part and statisfied all criteria but fields are invisble still.
Note: Size is 5.