Search code examples
oracleoracle-adfjdeveloperoracle-fusion-middleware

How to set value in input box programmatically in adf 12c


I am developing application in adf 12c with 12c database. I want to set value in input box programmatically, I have tried the following code but this didn't worked.

Here is the code of input box and button on which function is called:

<af:inputText value="#{bindings.Image.inputValue}" 
  label="Picture DB" rendered="true" simple="true" 
  required="#{bindings.Image.hints.mandatory}" 
  columns="#{bindings.Image.hints.displayWidth}" 
  maximumLength="#{bindings.Image.hints.precision}" 
  shortDesc="#{bindings.Image.hints.tooltip}" id="it66" 
  binding="#{FileManageBean.dbValue}">
 <f:validator binding="#{bindings.Image.validator}"/>
</af:inputText>

<af:button text="button 1" id="b2" action="#{FileManageBean.fileUpload}"/>

Here is the code of class and function:

public class File_Upl_Dwn {
    private RichInputText dbValue;

    public File_Upl_Dwn() {
        super();
    }


    public String fileUpload() { 

      //First Method I tried, but didn't worked
      getDbValue().setValue("gogog"); 
      AdfFacesContext adffacescontext1 = AdfFacesContext.getCurrentInstance();
      adffacescontext1.addPartialTarget(dbValue); 

      //Second Method I tried, but didn't worked
      getDbValue().setValue("sfdd");
      AdfFacesContext.getCurrentInstance().addPartialTarget(getDbValue());
      return "ok";
    }

    public void setDbValue(RichInputText dbValue) {
        this.dbValue = dbValue;
    }

    public RichInputText getDbValue() {
        return dbValue;
    }
}

Any help regarding how to enter value in input box programmatically will be really appreciated.


Solution

  • Try to add partialSubmit="true" in the button and partial trigger in inputText partialTriggers="b2" referring to the button

    <af:inputText value="#{bindings.Image.inputValue}" 
      label="Picture DB" rendered="true" simple="true"  
      required="#{bindings.Image.hints.mandatory}" 
      columns="#{bindings.Image.hints.displayWidth}" 
      maximumLength="#{bindings.Image.hints.precision}"  partialTriggers="b2"
      shortDesc="#{bindings.Image.hints.tooltip}" id="it66" 
      binding="#{FileManageBean.dbValue}">
     <f:validator binding="#{bindings.Image.validator}"/>
    </af:inputText>
    
    
    <af:button  text="button 1" id="b2" action="#{FileManageBean.fileUpload}" partialSubmit="true"/>