You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Caroline Jen <ji...@yahoo.com> on 2005/10/11 16:06:08 UTC

How to Access Another Class's Property Value That is Defined in the faces-config.xml?

I have a private property "dataTransferType" with
public getter and setter in the DataFile class.  The
initial value of the "dataTransferType" is defined in
the faces-config.xml file.  I want to get the "initial
value" of the "dataTransferType" in another class and
the compiler does not like the way I access this
property.

Here is the snippet of the DataFile class, which shows
the declaration and the getter and setter for the
property:

[code]
public class DataFile implements java.io.Serializable 
{
	private String dataTransferType;
	
	public DataFile(){}
	
    public DataFile( String aDataTransferType ) 
    {
        this.dataTransferType = aDataTransferType;
    }	
	
	public String getDataTransferType() 
	{
		return dataTransferType;
	}

	public void setDataTransferType( String
dataTransferType ) 
	{
		this.dataTransferType = dataTransferType;
	}
.....
}
[/code]

Here is the way that the initial value of the
"dataTransferPropery" is set in the faces-config.xml
file:

[code]
 <managed-bean>
  <managed-bean-name>dataFile</managed-bean-name>
 
<managed-bean-class>propertyBeans.DataFile</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
   <property-name>dataTransferType</property-name>
   <property-class>java.lang.String</property-class>
   <value>importFile</value>
  </managed-property>
 </managed-bean>
[/code]

Now, in another class FileManagementBean, I first
instantiate the DataFile class 

[code]
private DataFile datafile;
[/code]

and then in the constructor of the FileManagementBean
I tried to access the initial value of the property
"dataTransferType":
 
[code]
this.recordItems = this.getRecordsList(
datafile.dataTransferType );
[/code]

The compiler did not like it at all.

But, if I arbitrary introduced a String in the
FileManagementBean:

[code]
String defaultSelectedDataTransferType = "importFile";
......
......
this.recordItems = this.getRecordsList(
defaultSelectedDataTransferType );
[/code]

My code worked as I had expected without any problem.


		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs