jsf annotations

Posted by Andrew Bucknell on Stack Overflow See other posts from Stack Overflow or by Andrew Bucknell
Published on 2012-06-02T14:24:27Z Indexed on 2012/06/02 16:40 UTC
Read the original article Hit count: 201

Filed under:

I've created an address bean and I want to use it twice - once for street address and once for mailing address. I can achieve this using faces config as per the below, but I'm wondering if I can do this via annotations.

e.g. put @ManagedBean(name="StreetAddress") and @ManagedBean(name="MailingAddress") on the same class? I feel like I am missing something obvious here but I'm not sure what.

<managed-bean>
    <managed-bean-name>MailingAddress</managed-bean-name>
    <managed-bean-class>com.leetb.jsf_ex1.model.AddressBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <map-entries/>
</managed-bean>
<managed-bean>
    <managed-bean-name>StreetAddress</managed-bean-name>
    <managed-bean-class>com.leetb.jsf_ex1.model.AddressBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <map-entries/>
</managed-bean>

public class AddressBean {

    private String line_one;
    private String line_two;
    private String suburb;
    private String state;
    private String postcode;

/* getters and setters snipped */
}

© Stack Overflow or respective owner

Related posts about jsf-2.0