Entity Query problem
artur.chyzy May 7, 2007 12:08 PMHi. I want to make list filtering.
On the page i have some dataTable like
<rich:dataTable var="action" value="#{actionList.resultList}"
rendered="#{not empty actionList}"
rowClasses="rvgRowOne,rvgRowTwo" id="actionTable">
For filtering i have selectOneRadio and commandButton like
<h:selectOneRadio value="#{actionManager.actionFilter}">
<s:convertEnum />
<s:enumItem enumValue="ALL" label="All" />
<s:enumItem enumValue="SENT" label="Sent" />
<s:enumItem enumValue="NOT_SENT" label="Not sent" />
</h:selectOneRadio>
<h:commandButton action="#{actionManager.filterActions}" value="Filter"/>
For getting the list of actions i use entity query
@Name("actionList")
public class ActionQuery extends EntityQuery {
private static final long serialVersionUID = 4880758385999261380L;
private static final String[] RESTRICTIONS_ALL = { "" };
private static final String[] RESTRICTIONS_SENT = { "a.sent == 1" };
private static final String[] RESTRICTIONS_NOT_SENT = { "a.sent == 0" };
@Logger private Log log;
@In(required=false)
private ActionListFilter actionFilter;
@In
private ActionManager actionManager;
@Override
public String getEjbql() {
return "select a from Action a";
}
public List<String> getRestrictions() {
log.debug("filter bean: #0",actionManager.getActionFilter());
log.debug("actionFilter: #0",actionFilter);
if (actionFilter== null || actionFilter.equals(ActionListFilter .ALL)){
return new ArrayList<String>(0);
}
else if (actionFilter.equals(ActionListFilter .SENT)){
return Arrays.asList(RESTRICTIONS_SENT);
}
else if (actionFilter.equals(ActionListFilter .NOT_SENT)){
return Arrays.asList(RESTRICTIONS_NOT_SENT);
}
return new ArrayList<String>(0);
}
}
So as you can see above i building the restrictions according to option selected by user on the form. The problem is that the line
log.debug("actionFilter: #0",actionFilter);
return null, but later on the action the filter is not null (see bottom)
So the query is executed before my bean method.
I decided to get the value directly from bean but it is null.
Here are the logs
17:29:03,250 DEBUG [ActionQuery ] filter bean: null 17:29:03,250 DEBUG [ActionQuery ] actionfilter: null 17:29:03,250 DEBUG [ActionQuery ] filter bean: null 17:29:03,250 DEBUG [ActionQuery ] actionfilter: null 17:29:03,281 DEBUG [ActionManagerBean] actionfilter: SENT
For me the query is executed before form params gets updated.
In bean the value is correct.
Is this possible to create sth like this without using @Factory methods ?? (beacuse i this it should work in Factory... but may also not work)...
Anyone had similar problem or maybe know the solution