Search code examples
javaoracle-databaseuser-interfaceoracle-adfjdeveloper

UI Component issue onPageLoad method ADF oracle


I am facing problem in accessing the UI component (button) in the page in the onPageLoad() method. I am using ADF technology with JDveloper 11.1.2.3 the use case is:

I am trying to disable or enable a button in page load based on information coming form the database. in my situation am executing a query that check if there is a stored file in the database; if there is a file, a button for downloading should be enabled which allow the user to download this file other wise the download button should be disabled. I tried the following code in onPageLoad() method:

public void onPageLoad() {  

    // loading Previous file so the user have the option to download  

    // if there is privous file stored in db  
    if ((BlobDomain)tempVO.first().getAttribute("File1") != null) {  
        System.out.println("ther is file stored in db from onPage load");  
         this.downloadButton.setDisabled(false);  

    }  
    else {  
        // if there is no file stored the download option should be disapled  
        System.out.println("no file stored in db from onPage load");  
            this.downloadButton.setDisabled(true);  
    }  

and I got this errors after executing the previous code:

<UIXRegion> <_logIllegalContextChangeMessage> ADF_FACES-10026:During the processing of the region component, either a context change was not found or it did not match the instance set up by the current component. Expected oracle.adf.view.rich.component.fragment.UIXRegion$RegionContextChange but found UIXCollection.CollectionComponentChange[Component class: oracle.adf.view.rich.component.rich.data.RichTable, component ID: t1].
<RichExceptionHandler> <_logUnhandledException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5
oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null

Solution

  • Its just wrong approach.

    You should bind your file attribute in the bindings layer. Then use EL to check that its empty or not in your component property disabled.

    <af:inputFile disabled="#{bindings.File.inputValue == null}">