Showing posts with label BC. Show all posts
Showing posts with label BC. Show all posts

Monday 29 June 2015

How to know whether current row is new row or from database?

A row or view has four states:
  • New
  • Modified
  • Un-Modified
  • Initialized
To get the state using expression: #{row.row.entities[0].entityState}

You can use this expression to control the display or rows in the UI. Like to display new rows in diff colors.
    Ex: #{row.row.entities[0].entityState==0 ? 'background-color:yellow' :  ''} 
Now in RowImpl, you can access the state using:
    Ex: byte entityState = this.getEntity(0).getEntityState() 

Wednesday 27 August 2014

How to Get Application module object programmatically


You can use any of the below methods to get the application module programmatically.
>> private EmployeeAMImpl getAm() {

        FacesContext fctx = FacesContext.getCurrentInstance();
        DCBindingContainer dc =
            (DCBindingContainer)fctx.getApplication().getExpressionFactory().createValueExpression(fctx.getELContext(),
                                                                                                   DCBindingContainer.class).getValue(fctx.getELContext());
        return (WorkbenchAMImpl)dc.findDataControl("EmployeeAMDataControl").getApplicationModule();
    }
    

>> private EmployeeAMImpl getAm() {
        
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp =
            elFactory.createValueExpression(elContext, "#{data.EmployeeAMDataControl.dataProvider}",
                                            Object.class);
        return (WorkbenchAMImpl)valueExp.getValue(elContext);
    }