0

my problem is that I use a template in pages. This template has a SelectOneMenu. I want to actualize the new selection value in all pages using this template. It should be the same component. Do I need websockets for this or is it possible to actualize the selection of this selectOneMenu without websockets (event-based communication).

My code snippet:

<h:form prependId="false" id="masterTemplateForm">
        <p:menubar style="align">
            <p:menuitem value="Tab1">
            </p:menuitem>

            <p:menuitem value="Tab2">

            </p:menuitem>

            <p:menuitem value="Tab3">

            </p:menuitem>
            <f:facet name="options">
                <ui:insert name="tabTitle" />
                <p:outputLabel value="Benutzer: " />
                <p:selectOneMenu style="vertical-align:middle;" id="userSelect"
                    value="#{masterTemplateController.actualUser}"
                    converter="omnifaces.SelectItemsIndexConverter">
                    <f:selectItem itemLabel="-- Benutzer auswählen --" itemValue="#{null}" />
                    <f:selectItems var="currentUser"
                        value="#{masterTemplateController.findAllUser()}"
                        itemLabel="#{currentUser.benutzerName}" itemValue="#{currentUser}" />
                    <p:ajax update="userSelect" event="change" listener="#{masterTemplateController.selectUserHandler}" />
                </p:selectOneMenu>
            </f:facet>
        </p:menubar>
    </h:form>
    <ui:insert name="bodyContent" />

Thanks in advance for any hints.

LupoZ
  • 191
  • 1
  • 1
  • 12
  • please be more specific give more detail to understand your need – Yagami Light Feb 21 '17 at 12:53
  • _"Do I need websockets"_: yes – Kukeltje Feb 21 '17 at 13:09
  • @YagamiLight What I understood is that this selectOneMenu component has an id which should be sufficient for identification. I have different Pages which are using this template. The selection of a new value should also be updated and shown in the opened pages which are using this template. – LupoZ Feb 21 '17 at 13:09
  • @Kukeltje Even if I don't want to update all clients but just my session ? – LupoZ Feb 21 '17 at 13:09
  • multiple open pages of one user?: yes – Kukeltje Feb 21 '17 at 13:10
  • @Kukeltje Ok. I just had this selectOneMenu as a placeholder which is representing different users, for any future security / login implementation... – LupoZ Feb 21 '17 at 13:12
  • What Kukeltje want to say (and it's true) it can be one open active page for the user and changes can be applied if you don't refresh the page – Yagami Light Feb 21 '17 at 13:16
  • @YagamiLight Aye got that. So the solution is just implementing a refresh button on the other pages which performs the selection of the new value? Or polling... – LupoZ Feb 21 '17 at 13:20
  • 1
    yes it can be a solution the thing is for example if you are working in an accounting app the data that you show is something important you need to check the data version tell me if you need more informations – Yagami Light Feb 21 '17 at 13:23

0 Answers0