Yogesh Chaudhari wrote:
Hi,

I would like to read "show" managed property value in InvoiceBean
class constructor so I can populate different resultset in "invoices"
arraylist to display on page.

Thanks, Yogesh

public class InvoiceBean {
        private String show;
       ArrayList invoices;

        public InvoiceBean () {
                System.out.println("show invoices " + show);  
                invoices = getInvoices();
        }

<faces-config>
  <managed-bean>
    <managed-bean-name>invoiceALLBean</managed-bean-name>
    <managed-bean-class>org.adr.faces.backing.InvoiceBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
      <property-name>show</property-name>
      <property-class>java.lang.String</property-class>
      <value>ALL</value>
    </managed-property>
  </managed-bean>

  <managed-bean>
    <managed-bean-name>invoicePENDINGBean</managed-bean-name>
    <managed-bean-class>org.adr.faces.backing.InvoiceBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
      <property-name>show</property-name>
      <property-class>java.lang.String</property-class>
      <value>PENDING</value>
    </managed-property>
  </managed-bean>
..
..
..
</faces-config>


The short answer is you can't. Properties are set on a bean after it's constructed (since before it's constructed there's nothing to set a property on...).

You have a couple of options:

- call getInvoices() from setShow()

- call getInvoices() lazily when needed, after the show property has been set.

I'd recommend the latter but either would work.

L.

Reply via email to