Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#323 Customization of columns in collections is not stored sometimes

v4.7
closed
nobody
None
5
2013-04-09
2013-01-16
Javier Paniza
No

It fails because the tab object has no an update request. It only fail in some specific server configuration, so it difficult to test in a concrete way.

The solution is adding the next line in TabBaseAction:

protected Tab getTab() throws XavaException {
    if (tab == null ) {         
        String tabObject = Is.emptyString(getCollection())?"xava_tab":Tab.COLLECTION_PREFIX + Strings.change(getCollection(), ".", "_"); 
        tab = (Tab) getContext().get(getRequest(), tabObject);
        tab.setRequest(getRequest()); // ADD THIS LINE
        if (tab.getCollectionView() != null) {              
            tab.getCollectionView().refreshCollections();               
        }
    }
    return tab;
}

And improving ModuleManager to populate the object to inject in actions (among them is tab) with request. For example, in setObjectsToActionUseObjects() and setObjectsToActionInjectFields() we can add

        Object value = getObjectFromContext(objectName);            
        if (value == null) {                
            value = createObject(objectName);
            setObjectInContext(objectName, value);                  
        }
        updateRequest(value, request); // ADD THIS LINE

The code for updateRequest is:

private void updateRequest(Object value, HttpServletRequest request) {
    try {
        PropertiesManager pm = new PropertiesManager(value);
        if (pm.exists("request")) {
            pm.executeSet("request", request);
        }   
    }
    catch (Exception ex) {
        ex.printStackTrace(); // tmp some log
    }       
}

The above code has been tested in a configuration where we could reproduce the problem and it fix it.

Discussion

  • Javier Paniza
    Javier Paniza
    2013-04-09

    • status: open --> closed
    • milestone: v1.0_(example) --> v4.7