passing values between beans

Splash Forums PrettyFaces Users passing values between beans

This topic contains 1 reply, has 2 voices, and was last updated by  Lincoln Baxter III 2 years, 12 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24563

    rammer
    Participant

    I am having circular dependencies issues, however I think it’s because I am not using pretty faces correctly.

    I have 2 backing beans

    searchObject.java and manageObject.java

    the method in searchObject class is as follows:

    public String editResults() {
    		if ( null != selectedResults ) {
    			this.setRoleType(SIDCategoryEnumSI.PHYSICAL_RESOURCE.name());
    			this.setId(selectedResults.getId());
    			return "pretty:manageResourceRoleRoleType";
    		} else {
    		       return null;
    		}
    
    	}
    

    the manageObject class is below:

    
    
    @ViewScoped
    @URLMappings( mappings = {
    				@URLMapping( id = "manageResourceRole", pattern = "/physical/role/manageResourceRole/#{iid : manageResourceRole.id}", viewId = "/physical/role/manageResourceRole.jsf" ),
    				@URLMapping( id = "manageResourceRoleRoleType", pattern = "/physical/role/manageResourceRole/#{roleTypeTest : findResourceRole.roleType}/#{iid : findResourceRole.id}", viewId = "/physical/role/manageResourceRole.jsf" ),
    				@URLMapping( id = "manageResourceRoleBySpecification", pattern = "/physical/role/manageResourceRole/spec/#{manageResourceRole.roleType}/#{manageResourceRole.specificationId}", viewId = "/physical/role/manageResourceRole.jsf" ) } )
    public class ManageResourceRole extends AbstractBackingBean implements Serializable {
    	@URLAction(onPostback=false)
    	public void load() {
    	
    		tabBean.setActiveIndex( 2 );
    		if ( null != getId() ) { // Edit Object
                    } 
    
    }
    

    My question is, how do I get the values that are in the URL so that getID() can be accessed by the backing bean?

    the only thing I have tried that worked is this

            List<PathParameter> params = PrettyContext.getCurrentInstance().getCurrentMapping().getPatternParser().parse(PrettyContext.getCurrentInstance().getRequestURL());
    
    

    thanks.

    #24576

    Hello there!

    I believe what you are asking is how do you access the values that PrettyFaces has already injected into your beans via the path parameters you’ve specified in your URLMapping: #{roleTypeTest : findResourceRole.roleType}/#{iid : findResourceRole.id}

    If this is the case, then my suggestion would be to @Inject the FindResourceRole bean into your ManageResourceRole bean so that you can programmatically access them via the java API:

    http://www.mkyong.com/jsf2/injecting-managed-beans-in-jsf-2-0/

    However, using CDI is the preferred approach here:

    https://blogs.oracle.com/enterprisetechtips/entry/using_cdi_and_dependency_injection

    I hope this helps,

    Lincoln.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.