我正在尝试构建一些与其他选择框相关的选择框。我对Seam相当陌生-只需添加一下即可。这是我的JSF-为了测试,我试图显示一个dataTable
<f:facet name="header">Profil</f:facet>
<a:form ajaxSubmit="true" reRender="testTable">
<s:decorate id="techTypeField" template="layout/edit.xhtml">
<ui:define name="label">Choose tech</ui:define>
<h:selectOneRadio id="techType" value="#{technologyType}" onchange="submit()">
<s:selectItems value="#{technologyTypes}" var="elem" label="#{elem.name}" id="typeId"/>
<s:convertEntity/>
</h:selectOneRadio>
</s:decorate>
</a:form>
<div style="clear:both"/>
<h:dataTable var="productLine" id="testTable" value="#{productLines}" rendered="#{productLines.rowCount > 0}">
<h:column >
<f:facet name="header">pl</f:facet>
#{productLine.id}
</h:column>
</h:dataTable>
我的后援豆
package de.ac.dmg.productfinder.workflow;
import java.util.List;
import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.log.Log;
import de.ac.entity.Machine;
import de.ac.entity.ProductLine;
import de.ac.entity.TechnologyType;
@Stateful
@Name("Profil")
public class ProfilBean implements IProfil {
@PersistenceContext
private EntityManager entityManager;
@Logger
private Log log;
@DataModel(value = "technologyTypes")
private List<TechnologyType> technologyTypes;
@DataModelSelection(value = "technologyTypes")
private TechnologyType technologyType;
@DataModel(value = "productLines")
private List<ProductLine> productLines;
@DataModel(value = "machines")
List<Machine> machines;
@In
StatusMessages statusMessages;
// add additional action methods
@Factory("technologyTypes")
public void loadTechTypes() {
technologyTypes = entityManager.createQuery("Select t from TechnologyType t").getResultList();
}
@Factory("productLines")
public void loadProductLinies() {
System.out.println(technologyType);
productLines = entityManager.createQuery("select p from ProductLine p where p.technologyType = :type ")
.setParameter("type", technologyType).getResultList();
}
public void next() {
// implement your business logic here
log.info("Profil.next() action called with: #{Profil.value}");
statusMessages.add("next #{Profil.value}");
}
@Remove
public void destroy() {
}
}
我可以按时设置技术类型-单击一次后不会令人遗憾地刷新。我在这里做错了什么?
最佳答案
选择“技术类型”时,您需要执行一项操作,该操作根据所选技术类型重新加载产品类型。类似于action=#{Profil.loadProductLines()}
关于java - 接缝-具有依赖项的ListSelectMenus,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3447596/