Browse screen to associate browse screen with filter parameters filled out

Hey all.

I’ve got two questions. I’ve got a manifest entity, which contains multiple order entities.

First, when in a browse screen, you can select rows and add a click event to an row. I’m wondering if it is also possible to make the column level clickable on top of that. For example, if my manifest entity had attributes which stored the number of pending orders, and the number of cancelled orders, is it possible to make those columns clickable (on top of the row) so clicking on an attribute could open a new order-screen with only the pending orders of that manifest ?

Second, I’ve got to the point where I can click a row in my manifest browse, and it opens an order screen with only the orders of that manifest. Which looks like this:

On my manifest browse screen, Ive got the following itemclick override which sends the manifestId to an order browse screen:


    @Override
    public void init(Map<String, Object> params) {

        ManifestsTable.sortBy(ManifestsDs.getMetaClass().getPropertyPath("dateTime"), false);

        ManifestsTable.setItemClickAction(new BaseAction("Open orderBrowse of Manifest") {
            @Override
            public void actionPerform(Component component) {
                String manifestId = ManifestsTable.getSingleSelected().getId().toString();
                params.put("manifest", manifestId);
                openWindow("app$Order.browse", WindowManager.OpenType.NEW_TAB, params);
            }
        });

In my order browse screen, I’ve set a query filter to filter the orders by that manifestId:


        if (params.get("manifest") != null) {
            String manifestId = params.get("manifest").toString();
            LogicalCondition Condition = new LogicalCondition("", LogicalOp.AND);
            Condition.getConditions().add(new Clause("", "o.manifestShipmentidentifier in (select m from app$Manifest m where m.id =" + manifestId + ")", null, null, null));
            QueryFilter queryFilter = new QueryFilter(Condition);
            eyouOrdersDs.setQueryFilter(queryFilter);
            eyouOrdersDs.refresh();
}

I don’t know if this is the cleanest solution, but it works :slight_smile:

However, I would like to emphasize the fact that it’s a selected set of orders, by showing the manifest id attribute in the filter of the order browser, filled out by that id. Anyone got a suggestion on how that can be accomplished ?

Hi,

There is a sample project attached. Take a look.

The answer #1

You can use generated columns to create LinkButtons. The captions may be your values, the action will open the required screen. See the OrderBrowse.java:


public class OrderBrowse extends AbstractLookup {

    @Inject
    private GroupTable<Order> ordersTable;

    @Inject
    private ComponentsFactory componentsFactory;

    @Override
    public void ready() {
        super.ready();
        ordersTable.addGeneratedColumn("openOrderItems", entity -> {
            LinkButton linkBtn = componentsFactory.createComponent(LinkButton.class);
            linkBtn.setAction(new BaseAction("openOrderItes") {
                @Override
                public void actionPerform(Component component) {
                    Map<String, Object> params = ParamsMap.of("order", entity);
                    openWindow("samplefilter$OrderItem.browse", WindowManager.OpenType.NEW_TAB, params);
                }

                @Override
                public String getCaption() {
                    return "Open order items";
                }
            });
            return linkBtn;
        });
    }
}

The same sample answers the question #2. In the OrderItemBrowse.java the passed “order” parameter is analyzed and the filter entity is built:


public class OrderItemBrowse extends AbstractLookup {

    @WindowParam(name = "order")
    private Order order;

    @Inject
    private Filter filter;

    @Inject
    private Metadata metadata;

    @Override
    public void ready() {
        super.ready();
        if (order != null) {
            FilterEntity filterEntity = metadata.create(FilterEntity.class);
            filterEntity.setName("Order");
            String filterXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                    "\n" +
                    "<filter>\n" +
                    "  <and>\n" +
                    "    <c name=\"order\" class=\"com.company.samplefilter.entity.Order\" operatorType=\"EQUAL\" width=\"1\" type=\"PROPERTY\"><![CDATA[e.order.id = :component$filter.order37005]]>\n" +
                    "      <param name=\"component$filter.order37005\" javaClass=\"com.company.samplefilter.entity.Order\">" + order.getId() + "</param>\n" +
                    "    </c>\n" +
                    "  </and>\n" +
                    "</filter>\n";
            filterEntity.setXml(filterXml);
            filter.setFilterEntity(filterEntity);
            filter.apply(false);
        }
    }
}

Unfortunately, at the moment, the most convenient way to create a filter entity is to set an XML directly. We plan to simplify this in release 6.7. Probably you’ll be able to do it like you did in your sample: create a list of condition objects and set them to the filter entity.

sample-filter.zip (35.8K)

1 Like

Hey Max.

Thanks for the example. It looks perfect. I never would have figured out the building of the filter part on my own. I’m going to try to make the linkbuttons work on my own values.

Thanks again!