Page 1 of 1

Is this expected behavior?

Posted: Wed Jun 04, 2014 2:29 pm
by RapidTransit
So for my persistence provider I would have thought this would rename my order item in the admin view but as soon as it moves to the next property its overwritten :(

Code: Select all

    @Override
    public FieldProviderResponse extractValue(ExtractValueRequest extractValueRequest, Property property) {
        String entity = extractValueRequest.getEntity().getClass().getName();
        String clazz = DiscreteOrderItemImpl.class.getName();

        if(entity.equals(clazz)){
            if(property.getName().equals("name")){
                DiscreteOrderItem orderItem = (DiscreteOrderItem) extractValueRequest.getEntity();

                property.setValue(orderItem.getProduct().getDefaultCategory().getName() + " " + orderItem.getProduct().getName() + " " + orderItem.getName());
                property.setDisplayValue(orderItem.getProduct().getDefaultCategory().getName() + " " + orderItem.getProduct().getName() + " " + orderItem.getName());

                return FieldProviderResponse.HANDLED;
            }
        }
        return FieldProviderResponse.NOT_HANDLED;
    }


Hacky work around

Code: Select all

    @Override
    public FieldProviderResponse extractValue(ExtractValueRequest extractValueRequest, Property property) {
        String entity = extractValueRequest.getEntity().getClass().getName();
        String clazz = DiscreteOrderItemImpl.class.getName();

        if(entity.equals(clazz)){
                DiscreteOrderItem orderItem = (DiscreteOrderItem) extractValueRequest.getEntity();
                String name = orderItem.getProduct().getDefaultCategory().getName() + " " + orderItem.getProduct().getName() + " " + orderItem.getName();
                List<Property> props = extractValueRequest.getProps();

                for(int i =0; i < props.size(); i++){
                    if(props.get(i).getName().equals("name")){
                        props.get(i).setValue(name);
                        break;
                    }
                }
                return FieldProviderResponse.HANDLED;
        }
        return FieldProviderResponse.NOT_HANDLED;
    }

Re: Is this expected behavior?

Posted: Thu Jun 05, 2014 1:07 pm
by phillipuniverse
Try returning FieldProviderResponse.HANDLED_BREAK instead.

Re: Is this expected behavior?

Posted: Thu Jun 05, 2014 8:37 pm
by RapidTransit
I'll try it again since I tried it with JRebel, the last JRebel update has been acting kind of strange, refusing to reload classes, breakpoints aren't getting caught, and crashing the VM :lol:

Re: Is this expected behavior?

Posted: Fri Jun 06, 2014 10:35 am
by phillipuniverse
Yeah sometimes it's a JRebel thing, sometimes it's actually an Eclipse thing. I've noticed that there are times when Eclipse has not rebuilt the class file and thus JRebel doesn't know that it should reload it. If you have automatic building turned on, this is usually the result of having errors in your build path. You can see those errors in the Problems view in Eclipse and it will also have a big ! next to the project itself in the Project/Package Explorer.

Also, I've noticed that being on the latest version of JRebel helps too. We used to have some weird compatibility problems when we used GWT but since we have abandoned that the latest version usually works. Crashing the VM though; that's a new one that I can't say I'm entirely surprised by :roll: