ViewScoped 인 관리 빈이 있습니다. 이 콩에서는 (h : commandButton을 사용하여) 폼을 보내야합니다. 이벤트를 발생시키고 페이지를 업데이트하는 드롭 다운 메뉴 항목을 변경하는 경우를 제외하고는 정상적으로 작동합니다. 드롭 다운 메뉴의 값을 변경 한 후, 양식을 제출하면 Bean이 다시 작성되고 h : commandButton과 연관된 조치는 건너 뜁니다.폼 액션을 호출하는 대신 ViewScoped bean을 다시 생성했습니다.
여기 내 XML의 :
<rich:panel styleClass="panel_grid_center fifty_percent"
header="Bid matrix">
<!-- display in case the user is not an admin -->
<h:panelGroup rendered="#{not loginBean.isAdmin}">
<h:outputText
value="You do not have sufficient permission to view this page." />
<br />
<h:form>
<h:commandLink action="index.xhtml"
value="Click here to go back to login page/search page." />
</h:form>
</h:panelGroup>
<!-- display if the user is an admin -->
<h:panelGroup rendered="#{loginBean.isAdmin}" id="bid_matrices_panel">
<h:panelGrid columns="2">
<!-- customer group panel -->
<rich:panel styleClass="contained_width fifty_percent"
header="Customer group">
<h:form>
<h:selectOneMenu
valueChangeListener="#{adminBean.onCustomerGroupChangeListener}"
value="#{adminBean.customerGroupService.displayCustomerGroup.spendMinimum}">
<f:selectItems
value="#{adminBean.customerGroupService.customerGroups}"
var="group" itemLabel="#{group.customerGroupLabel}"
itemValue="#{group.spendMinimum}" />
<a4j:ajax event="valueChange" execute="@this"
render="bid_matrices_panel" />
</h:selectOneMenu>
</h:form>
</rich:panel>
<!-- repeatables -->
<rich:panel styleClass="contained_width fifty_percent"
header="Repeatables">
</rich:panel>
</h:panelGrid>
<h:form>
<!-- we loop on each different commoditization (or however that's spelled) -->
<a4j:repeat var="bidmatrix_by_commoditization"
value="#{adminBean.bidMatrices}">
<rich:dataTable styleClass="contained_width"
value="#{bidmatrix_by_commoditization.bidMatricesByCoreStatus}"
var="matrix_by_core_status">
<!-- Display core status -->
<rich:column>
<f:facet name="header">
<h:outputText
value="#{bidmatrix_by_commoditization.commoditization}" />
</f:facet>
<h:outputText value="#{matrix_by_core_status.coreStatus}" />
</rich:column>
<!-- the percentages -->
<c:forEach var="index" begin="0"
end="#{adminBean.columnsNumber - 1}">
<rich:column>
<f:facet name="header">
<h:outputText value="#{adminBean.columnsHeaders[index]}" />
</f:facet>
<h:inputText
value="#{matrix_by_core_status.bidMatrices[index].percentage}">
<f:convertNumber type="percent" />
</h:inputText>
</rich:column>
</c:forEach>
</rich:dataTable>
</a4j:repeat>
<br />
<!-- update matrix button -->
<h:commandButton value="Update" action="#{adminBean.update}" />
</h:form>
</h:panelGroup>
</rich:panel>
내 콩 : 내가 제대로 나는 또한 내 콩에서의 getter/setter를 제거하지만, 거기에 javax.faces.bean.ViewScoped;
에서 ViewScoped를 가져
@ManagedBean(name = "adminBean")
@ViewScoped
public class AdminBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5917562235108703019L;
private CustomerGroupService customerGroupService;
private BidMatrixDao bidMatrixDao;
private List<BidMatricesByCommoditization> bidMatrices;
@PostConstruct
public void init() {
customerGroupService = new CustomerGroupService();
bidMatrixDao = new BidMatrixDaoImpl();
bidMatrices = bidMatrixDao.getBidMatricesByCustomerGroup(customerGroupService.getDisplayCustomerGroup());
}
public void onCustomerGroupChangeListener(ValueChangeEvent v) {
customerGroupService.setDisplayCustomerGroup((BigDecimal) v.getNewValue());
bidMatrices = bidMatrixDao.getBidMatricesByCustomerGroup(customerGroupService.getDisplayCustomerGroup());
}
public CustomerGroupService getCustomerGroupService() {
return customerGroupService;
}
/**
* @param customerGroupService
* the customerGroupService to set
*/
public void setCustomerGroupService(CustomerGroupService customerGroupService) {
this.customerGroupService = customerGroupService;
}
/**
* @return the bidMatrices
*/
public List<BidMatricesByCommoditization> getBidMatrices() {
return bidMatrices;
}
/**
* @param bidMatrices
* the bidMatrices to set
*/
public void setBidMatrices(List<BidMatricesByCommoditization> bidMatrices) {
this.bidMatrices = bidMatrices;
}
public int getColumnsNumber() {
return bidMatrices.get(0).getColumns();
}
public List<String> getColumnsHeaders() {
return bidMatrixDao.getAlignments();
}
public void update() {
bidMatrixDao.updateBidMatrices(bidMatrices);
}
}
참고. 내가 말했듯이, h : selectOneMenu 값을 변경하지 않고 양식을 제출하면 제대로 작동합니다.
감사합니다.
편집 :
<a4j:ajax event="valueChange" execute="@this" render="bid_matrices_panel" />
내가 원래를 넣어 : 나는 제이보스 10.1
JSF의 IMPL 및 버전을 까맣게 잊고
확신? Richfaces 버전? – Kukeltje
JSF 2.2는 JSF 구현 및 버전이 아닌 API 사양입니다. Wildfly 10.1 사용? – Kukeltje