Monday, December 7, 2009

JSF Controller accessibility in other Controller

  
   Define configuration files for the backing bean/controller as follows.
 
    [managed-bean id="Controller"]
        [managed-bean-name]Controller[/managed-bean-name]
        [managed-bean-class]
            Path.Controller
        [/managed-bean-class]
        [managed-bean-scope]request[/managed-bean-scope]
        [managed-property]
            [property-name]injectedData[/property-name]
            [value]#{InjectedController}[/value]
        [/managed-property]
    [/managed-bean]
    
Then, the  data need to be injected to this backing bean is define separately.
    [managed-bean id="InjectedController"]
        [managed-bean-name] InjectedController [/managed-bean-name]
        [managed-bean-class]
            Path. InjectedController
        [/managed-bean-class]
        [managed-bean-scope]request[/managed-bean-scope]
    [/managed-bean]

 Need to make sure that there should be proper getter and setter methods for the 
 injectedData in the Controller Class mentioned below, which helps to access the injectedData in the pages

   Public class Controller {
      ...
           Public getInjectedData(){
             ...
           }
           Public setInjectedData(dataTyle data){
              this.injectedData = data;
           }
    }

No comments:

Post a Comment