我要实现,在国家和城市之间,基于类似于此示例的其他selectOneMenu填充selectOneMenu https://www.primefaces.org/showcase/ui/ajax/dropdown.xhtml 但我不知道如何实现:
豆
package unjfsc.jsf;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import unjfsc.model.send;
import unjfsc.model.repart;
import unjfsc.service.sendservice;
@ManagedBean(name="sendbean01")
@SessionScoped
public class sendbean
{
private send sendi;
private sendservice sendiservice = new sendservice();
private List<send> listcrg;
private int size_list;
public sendbean()
{
sendi = new send();
}
public void addsend() throws Exception
{
send objsend = new send();
objsend.setId_send(sendi.getId_envio());
objsend.setAddress(sendi.getAddress());
objsend.setDep(sendi.getDep());
objsend.setCountry(sendi.getCountry());
objsend.setCity(sendi.getCity());
objsend.setCod(sendi.getCod());
objsend.setF_send(sendi.getF_send());
objsend.setPrice(sendi.getPrice());
sendiservice.addsend(objsend);
}
public void listsend() throws Exception
{
send obj = new send();
obj.setF_send(sendi.getF_send());
listcrg=sendiservice.listsend(obj);
size_list=listcrg.size();
}
}
<h:body>
<h:form>
<table border="2" align="center" cellpadding="10">
<tr>
<td><h:outputText value="Id: "></h:outputText> </td>
<td>
<h:inputText value="#{sendbean01.sendi.id_send}"></h:inputText>
</td>
</tr>
<tr>
<td><h:outputText value="address:"></h:outputText></td>
<td>
<h:inputText value="#{sendbean01.sendi.address}"></h:inputText>
</td>
</tr>
<tr>
<td><h:outputText value="Dep:"></h:outputText></td>
<td>
<p:selectOneMenu value="#{sendbean01.sendi.dep}">
<f:selectItem itemLabel="-Select-" itemValue=""></f:selectItem>
<f:selectItem itemLabel="dep1" itemValue="dep1"></f:selectItem>
</p:selectOneMenu>
</td>
</tr>
<tr>
<td><h:outputText value="country:"></h:outputText></td>
<td>
<p:selectOneMenu value="#{sendbean01.sendi.country}">
<f:selectItem itemLabel="-Select-" itemValue=""></f:selectItem>
<f:selectItem itemLabel="country1" itemValue="country1"></f:selectItem>
</p:selectOneMenu>
</td>
</tr>
<tr>
<td><h:outputText value="City:"></h:outputText></td>
<td>
<p:selectOneMenu value="#{sendbean01.sendi.city}">
<f:selectItem itemLabel="-Select-" itemValue=""></f:selectItem>
<f:selectItem itemLabel="city1" itemValue="city1"></f:selectItem>
<f:selectItem itemLabel="city2" itemValue="city2"></f:selectItem>
<f:selectItem itemLabel="city3" itemValue="city3"></f:selectItem>
<f:selectItem itemLabel="city4" itemValue="city4"></f:selectItem>
<f:selectItem itemLabel="city5" itemValue="city5"></f:selectItem>
</p:selectOneMenu>
</td>
</tr>
<tr>
<td><h:outputText value="Cod:"></h:outputText></td>
<td>
<h:inputText value="#{sendbean01.sendi.cod}"></h:inputText>
</td>
</tr>
<tr>
<td><h:outputText value="Date"></h:outputText></td>
<td>
<p:calendar value="#{sendbean01.sendi.f_send}" mode="popup" showOn="button" popupIconOnly="true" pattern="dd/MM/yyyy">
</p:calendar>
</td>
</tr>
<tr>
<td><h:outputText value="Price"></h:outputText></td>
<td>
<h:inputText value="#{sendbean01.sendi.price}"></h:inputText>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<p:commandButton value="Add" actionListener="#{sendbean01.addsend}" icon="ui-icon-car">
<p:confirm header="Confirm" message="insurance?" icon="ui-icon-alert"/>
</p:commandButton>
<p:confirmDialog global="true">
<p:commandButton value="Si" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
</p:confirmDialog>
</td>
</tr>
</table>
</h:form>
</h:body>
请大家帮忙,根据国家和城市之间的其他selectOneMenu填充selectOneMenu。