Hi! I am trying to add a text field upon clicking a radio button but it doesn't seem to work. What I want to do is display different text fields depending on the radio button clicked. It prints the message "done" but it won't load/add the textfield. Am I missing some code? What do I need to add to this to make it work? What is rendering, is it what I need to do? Thank you.
Code:
public class Upload {
Widget page = new Widget();
final FormPanel mainPanel = new FormPanel();
public Uploasd(String wholeName, final int user_id, final int schId) {
mainPanel.setHeading("Upload Work");
mainPanel.setEncoding(Encoding.MULTIPART);
mainPanel.setMethod(Method.POST);
mainPanel.setWidth(775);
FormLayout fLayout1 = new FormLayout();
fLayout1.setLabelWidth(110);
fLayout1.setPadding(5);
mainPanel.setLayout(fLayout1);
FileUploadField file = new FileUploadField();
file.setAllowBlank(false);
file.setFieldLabel("File");
mainPanel.add(file);
RadioGroup license = new RadioGroup("privacy");
license.setFieldLabel("Privacy");
license.add(radio);
license.add(radio2);
license.add(radio3);
mainPanel.add(license);
final Radio tList = new Radio();
tList.setWidth(120);
tList.setName("assess");
tList.setId("2");
tList.setBoxLabel("from list");
tList.setToolTip("choose from the complete list of evaluators in the system");
tList.setValue(true);
final Radio rubric = new Radio();
rubric.setName("assess");
rubric.setId("1");
rubric.setItemId("1");
rubric.setWidth(120);
rubric.setToolTip("choose from teachers with the specified rubric keyword");
rubric.setBoxLabel("with rubric...");
rubric.setValue(false);
RadioGroup assessors = new RadioGroup("evaluators");
assessors.setFieldLabel("Evaluators");
assessors.add(tList);
assessors.add(rubric);
mainPanel.add(assessors);
final TextField testing1 = new TextField();
testing1.setFieldLabel("Teacher's Name");
testing1.setBorders(true);
final HorizontalPanel testPanel1 = new HorizontalPanel();
testPanel.add(testing1);
final TextField testing2 = new TextField();
testing2.setFieldLabel("Teacher's Name");
testing2.setBorders(true);
final HorizontalPanel testPanel2 = new HorizontalPanel();
testPanel.add(testing2);
tList.addListener(Events.OnClick, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
if (be.field.getId() == "2") {
mainPanel.add(testPanel);
System.out.println("done1");
}
}
});
rubric.addListener(Events.OnClick, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
if (be.field.getId() == "1") {
mainPanel.add(testPanel2);
System.out.println("done2");
}
}
});
page = mainPanel;
}
public Widget getWidget() {
return page;
}
}