This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Oct 24, 2011, 10:41 PM
57 Posts

Difference between property configuration in face-config.xml/.xsp property file and class constructor

  • Category: APIs
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: faces-config.xml
  • Replies: 4
Difference between been property configuration in face-config.xml/.xsp property file and setter method in class constructor, anyone can let me know?
 
 
Oct 25, 2011, 6:15 PM
149 Posts
Re: Difference between property configuration in face-config.xml/.xsp property file and cl...
 
 
Maybe it's just me, but your question seem to miss some important information
Oct 25, 2011, 10:04 PM
57 Posts
Re: Difference between property configuration in face-config.xml/.xsp property file and cl...
Lets take an example
Java Class:
public class Person{
    public String Name;
 
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
 
   public Person(){
   } 
 
   public Person(String name) {
        super();
        this.name = name;
   }
 
}
 
Java class in property file
<managed-bean>
  <managed-bean-name>Person</managed-bean-name>
  <managed-bean-class>com.something</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>                                             
  <managed-property>
    <property-name>Name</property-name>
    <value>Thomas</value>
  </managed-property> 
<managed-bean>
 
both Java constructor and class definition in property file will create a class instance with default Name, is there any advantage doing it in property file? Difference in Object lifecycle, I suppose that class instance is created before rendering for property configuration ? Because of the empty constructor ?
http://www.oracle.com/technetwork/topics/index-101145.html

Oct 26, 2011, 3:46 AM
1 Posts
Re: Difference between property configuration in face-config.xml/.xsp property file and cl...
 I think yours managed-bean declaration is a little mistaken:
 
package com.acme; 
 
public class Person{
    public String Name; //you have to be careful with case ;)
    public String name;
 
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
 
   public Person(){
   } 
 
   public Person(String name) {
        super();
        this.name = name;
   } 

 
}
 
Java class in property file
<managed-bean>
  <managed-bean-name>person</managed-bean-name>
  <managed-bean-class>com.acme.Person</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>                                             
  <managed-property>
    <property-name>name</property-name>
    <value>Thomas</value>
  </managed-property> 
<managed-bean>

The above creates a object instance named "person" of a type "Person". And sets the property "name" of that object with the value "Thomas".
 
This is part of JSF platform that XPages implements and, the java code have to use Java Bean convention with getters and setters. 
The advantage of this is that object is declared globally to your XPages application and you can access even in you SSJS code. 
 
So, if you write your faces-config.xml with that declaration, You can create a XPages, put a editbox on it and bind the data with that bean. 
 
 
 
 
 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal