I want to update the second SelectOneMenu when I select any item of the first SelectOnMenu.So there are my two SelectOneMenu:
<p:outputLabel value="Table :" />
<p:selectOneMenu id="tbName">
<f:selectItem itemLabel="Select Table" itemValue="" />
<f:selectItems value="#{infoTable.nameTa}" />
</p:selectOneMenu>
<p:outputLabel value="Foreignenkey :" />
<p:selectOneMenu id="cat">
<f:selectItem itemLabel="Select Column" itemValue="" />
<f:selectItems value="#{infoTable.fkName}" />
</p:selectOneMenu>
and this is his Java code :
public List<SelectItem> getNameTa() {
List<SelectItem> subcat = new ArrayList<SelectItem>();
try {
ConnectionBase con = new ConnectionBase();
TableInfo tt = new TableInfo();
List<String> rs = tt.getTable(con, "%");
Iterator i = rs.iterator();
while (i.hasNext()) {
subcat.add(new SelectItem(i.next()));
}
} catch (Exception e) {
e.getStackTrace();
}
return subcat;
}
public List<SelectItem> getFkName() {
List<SelectItem> subcat = new ArrayList<SelectItem>();
// if (catname != null && !catname.equals("")) {
try {
// Connection con = Database.getConnection();
ConnectionBase con = new ConnectionBase();
TableInfo tt = new TableInfo();
List<String> rs = tt.getNameCtable(con, "%");
Iterator i = rs.iterator();
while (i.hasNext()) {
subcat.add(new SelectItem(i.next()));
}
} catch (Exception ex) {
}
// }
return subcat;
}
As i know i should make a eventLestner but i don't know how and when i get the name of table from the first selectonemenu how can send the name to the second methode "getFkName" ?