我的仪表板上有一些链接,链接到myCustomers或allCostomerThatRegisteredY昨天。我使用了应用程序文件夹。可用性是一个仪表板,快速链接甚至更好。
如何使用过滤器调用openWindow(" screen-id",WindowType,filterMap?)?
答案 0 :(得分:4)
这里有两个选项:
<collectionDatasource id="booksDs"
class="com.company.opentest.entity.Book"
view="_local">
<query>
<![CDATA[select e from opentest$Book e]]>
<filter>
<and>
<c>e.author.id = :param$bookAuthor</c>
</and>
</filter>
</query>
</collectionDatasource>
在这种情况下,如果您在bookAuthor
方法的params参数中传递openWindow
参数,则将应用此查询过滤器。
Map<String, Object> params = new HashMap<>();
params.put("bookAuthor", author);
openWindow("opentest$Book.browse", WindowManager.OpenType.NEW_TAB, params);
init()
方法的参数映射,如果有特殊参数,您将通过JPQL找到所需的过滤器实体(sec$Filter
)查询。然后将此实体设置为Filter组件(Filter#setFilterEntity(...)
),指定过滤器参数(Filter#setParamValue(...)
)并应用过滤器(Filter#apply()
)。获取过滤器参数名称(author84104)在setParamValue()
方法javadoc和过滤器组件文档中进行了描述。
public class BookBrowse extends AbstractLookup {
@Inject
private Filter filter;
@Inject
private DataManager dataManager;
private Author bookAuthorParam;
@Override
public void init(Map<String, Object> params) {
super.init(params);
bookAuthorParam = (Author) params.get("bookAuthor");
}
@Override
public void ready() {
super.ready();
if (bookAuthorParam != null) {
setAuthorFilter(bookAuthorParam);
}
}
private void setAuthorFilter(Author bookAuthor) {
FilterEntity filterEntity = findFilterEntity();
if (filterEntity != null) {
filter.setFilterEntity(filterEntity);
filter.setParamValue("author84104", bookAuthor);
filter.apply(false);
}
}
private FilterEntity findFilterEntity() {
LoadContext<FilterEntity> ctx = new LoadContext<>(FilterEntity.class)
.setView("app");
ctx.setQueryString("select f from sec$Filter f where f.componentId = :componentId and f.name = :name")
.setParameter("componentId", "[opentest$Book.browse].filter")
.setParameter("name", "By author");
return dataManager.load(ctx);
}
}