0

I'm not expert in JSF..

There is a bean.

@ManagedBean
@ViewScoped
public class ClientBean

Also the code has class Client (not a bean. just a class)

Actually ClientBean duplicate all fields from Client. What's not good. Duplication I mean itself.

It seems the reason of duplication is to provide the annotations over the fields that ClientBean duplicates/has. Like:

@NotEmpty
@KeyFormat
private String key;

What would be the best way to reduce duplications? Let's say wrap Client by ClientBean.. Extends Client by ClientBean.. to be able to use annotation advantage.

ses
  • 13,174
  • 31
  • 123
  • 226

1 Answers1

0

Your ClientBean has field Client:

@ManagedBean
@ViewScoped
public class ClientBean{
    private Client client;

    private Client getClient(){
       return client;
    }
}

And you can use EL like this #{clientBean.client.name}

If you want to reduce this long EL, you can use JSTL(xmlns:c="http://java.sun.com/jsp/jstl/core") :

<c:set var="client" value="#{clientBean.client}"/>

And your expressions will be like this #{client.name}

Rest
  • 11
  • 2