0

Hello I'm using Primefaces (5.2 currently). I'm novice in JSF so what I'm thinking about shouldn't be possible. Please correct me if I'm wrong :)

I'm creating simple application with registration. Administrator can edit registered users, etc.

So I just want to simplify development with templates.

For example I've created template:

<ui:composition>
    <p:panel id="#{userPanelId}">
        <div>
            <p:outputLabel value="#{label['userBean.user.firstName']}" for="firstName"/>
            <p:inputText value="#{userView.user.firstName}" id="firstName"
                         label="#{label['userBean.user.firstName']}"/>
            <p:message for="firstName"/>
        </div>
        <div>
            <p:outputLabel value="#{label['userBean.user.lastName']}" for="lastName"/>
            <p:inputText value="#{userView.user.lastName}" id="lastName"
                         label="#{label['userBean.user.lastName']}"/>
            <p:message for="lastName"/>
        </div>
        <div>
            <p:outputLabel value="#{label['userBean.user.email']}" for="userEmail"/>
            <p:inputText value="#{userView.user.email}" id="userEmail"
                         label="#{label['userBean.user.email']}"/>
            <p:message for="userEmail"/>
        </div>
        <ui:insert name="userPanelExtension"/>
    </p:panel>
</ui:composition>

My userView is @RequestScoped (or in spring by @Scope(request)). I realised that it would be useful to have this bean for both scopes @RequestScoped and @SessionScoped.

  1. is is it possible to have one abstract userView an then extend it and create userViewRequestScoped userViewSessionScoped for example?

  2. is it then possible to parametrise name of view bean in template file? For example in

    <p:inputText value="#{userView.user.firstName}" id="firstName" />
    

    have something like

    <p:inputText value="#{${parametrisedBeanName}.user.firstName}" id="firstName" />
    

Thanks in advance

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
bilak
  • 4,526
  • 3
  • 35
  • 75
  • Even though the Q is a bit different, the answer applies as well: http://stackoverflow.com/questions/16842912/passing-the-backing-bean-as-a-parameter-to-a-facelet-include/ Is this acceptable as dupe? – BalusC Apr 16 '15 at 11:50
  • Looks promising. So in my scenario I will add parameter and then in decorator or include use ? Am I right? What about abstract bean, will it work? Thanks. – bilak Apr 16 '15 at 12:06
  • That's in turn a question you can easily answer yourself by just trying out. We're generally not interested in answering rhetorical questions. – BalusC Apr 16 '15 at 12:07
  • BalusC what you suggested is working. Please add answer to this thread and I will mark it as correct answer. Thank you. – bilak Apr 16 '15 at 12:34

0 Answers0