filterMethod
에 제공된 메소드를 실행하지 않는 리치 스 페이스 3.3이있는 필터가 있습니다.richfaces 외부 필터링 : filterMethod를 실행하지 않습니다.
필터 :
<r:column filterMethod="#{orderSearchFilter.filterStateText}" >
<f:facet name="header">
<h:selectOneMenu value="#{orderSearchFilter.filterValueStateText}">
<f:selectItems value="#{orderSearchFilter.filterListStateTexts}" />
<a:support event="onchange" reRender="orders,dataScroller_foot" />
</h:selectOneMenu>
</f:facet>
<h:outputText value="#{_data.status}"/>
</r:column>
필터링 콩 : 내가 다른 구현을 발견
import java.util.ArrayList;
import javax.faces.model.SelectItem;
import org.jboss.seam.annotations.Name;
import ch.ildsoftware.gvs.order.OrderItem;
@Name("orderSearchFilter")
public class OrderSearchFilter {
private ArrayList<SelectItem> filterListStateTexts = new ArrayList<SelectItem>();
private String filterValueInventoryNr="";
private String filterValueSerialNr="";
private SelectionStateText filterValueStateText;
public OrderSearchFilter() {
for(SelectionStateText sT : SelectionStateText.values()) {
SelectItem select = new SelectItem();
select.setLabel(sT.label());
select.setValue(sT);
filterListStateTexts.add(select);
}
}
public ArrayList<SelectItem> getFilterListStateTexts() {
return filterListStateTexts;
}
public String getFilterValueInventoryNr() {
return filterValueInventoryNr;
}
public void setFilterValueInventoryNr(String filterValueInventoryNr) {
this.filterValueInventoryNr = filterValueInventoryNr;
}
public String getFilterValueSerialNr() {
return filterValueSerialNr;
}
public void setFilterValueSerialNr(String filterValueSerialNr) {
this.filterValueSerialNr = filterValueSerialNr;
}
public SelectionStateText getFilterValueStateText() {
return filterValueStateText;
}
public void setFilterValueStateText(SelectionStateText filterValueStateText) {
this.filterValueStateText = filterValueStateText;
}
public Boolean filterStateText(Object current) {
OrderItem item = (OrderItem) current;
SelectionStateText state = getFilterValueStateText();
for(String status : state.states()) {
if (status.isEmpty() || status.equals(item.getStatus()))
return true;
}
return false;
}
public Boolean getFilterStateText(Object current) {
OrderItem item = (OrderItem) current;
SelectionStateText state = getFilterValueStateText();
for(String status : state.states()) {
if (status.isEmpty() || status.equals(item.getStatus()))
return true;
}
return false;
}
}
get
접두사로 한 번, 두 번 기록 된 방법이있다, 그 이유입니다. 이제는 기본적으로 다음 예제를 계속 사용했습니다. http://livedemo.exadel.com/richfaces-demo/richfaces/filteringFeature.jsf?tab=ex-usage&cid=4110192
디버거에서 볼 수있는 필터 값은 (setFilterValueStateText
)이지만 필터 메서드도 호출되지 않습니다.
모든 나는 그것이 filterMethod
후 문자열이 FilterField
(안 ExtendedFilterField
)로 팝업 다른 클래스의 modify()
방법에 점프 것을 볼 수 있지만 필터링 빈은 현재 값으로 접근 할 수 없다. 이 클래스에서는 다른 필터가 처리됩니다.
public class OrderSearchDataModel extends QueryDataModel implements Modifiable
{
private OrderSearchCriteria orderSearchCriteria;
public OrderSearchDataModel(OrderSearch query)
{
super(query);
}
@Override
public void modify(List<FilterField> filterFields,
List<SortField2> sortFields)
{
if (filterFields != null && !filterFields.isEmpty()) {
ExtendedFilterField extendedFilterField = null;
String value = null;
Expression expression = null;
String expressionStr = null;
orderSearchCriteria = new OrderSearchCriteria();
for (FilterField filterField : filterFields) {
if (filterField instanceof ExtendedFilterField) {
extendedFilterField = (ExtendedFilterField) filterField;
value = extendedFilterField.getFilterValue();
if (value != null && !value.equals("")) {
expression = extendedFilterField.getExpression();
expressionStr = expression.getExpressionString();
if (!expression.isLiteralText()) {
expressionStr = expressionStr.
replaceAll("[#|$]{1}\\{.*?\\.", "").
replaceAll("\\}", "");
}
if (expressionStr.equals("inventoryNr"))
orderSearchCriteria.setInventoryNr(value);
if (expressionStr.equals("serialNr"))
orderSearchCriteria.setSerialNr(value);
OrderSearch orderSearch = (OrderSearch) getQuery();
orderSearch.setSearchCriteria(orderSearchCriteria);
}
}
}
}
Set<SortField2> validSortFields = new HashSet<SortField2>();
for (SortField2 sortField : sortFields)
{
if (!sortField.getOrdering().equals(Ordering.UNSORTED))
validSortFields.add(sortField);
}
if (validSortFields.size() == 1)
{
SortField2 sortfield = validSortFields.iterator().next();
ValueExpression expression = (ValueExpression) sortfield
.getExpression();
OrderSearchField field = (OrderSearchField) expression.getValue(FacesContext
.getCurrentInstance().getELContext());
boolean asc = sortfield.getOrdering().equals(Ordering.ASCENDING);
Sorting<OrderSearchField> sorting = new Sorting<OrderSearchField>(
field, asc);
OrderSearch orderSearch = (OrderSearch) getQuery();
orderSearch.setSorting(sorting);
}
else if(validSortFields.size() > 1) throw new FacesException("multiple column sorting is not suported");
}
}
무엇이 잘못 되었나요?