0

I want to update two components after ajax action but don't know how to do this (if it is even possible). I have three pages:

           <h:form id="loginForm"> 
                <p:panelGrid columns="2" >
                    <h:outputText value="Login: "/>
                    <p:inputText value="#{bean.person.username}" requiredMessage="*" /> 
                    <h:outputText value="Hasło: "/>
                    <p:password value="#{bean.person.password}" requiredMessage="*"/>                        
                    <p:commandButton value="Login" action="#{bean.validatePerson}" update="loginConfirmationPage"/>
                </p:panelGrid>
            </h:form>

Menu page is similar to this above with menu items with rendered atribute (fe. show logout button when user is logged in) and loginConfirmationPage on which i want to show username.

I need to update both of these pm:pages to get logout button on menu page and also display username on confirmation page. How can I do this? For now i can only update one page. I tried to type statement similar to these:

<p:commandButton value="Login" action="#{bean.validatePerson}" update="loginConfirmationPage,menuPage"/>

or

<p:commandButton value="Login" action="#{bean.validatePerson}" update="loginConfirmationPage;menuPage"/>

Both not working. How can i do this?

Hondus
  • 292
  • 1
  • 4
  • 16
  • Press F12 in the browser Firefox / Chrome, select HTML / Elements tab, press the arrow / magnifying glass icon and select / search for the id attribute corresponding to the elements you want to update. One of these could contain a colon charecter because it is placed in a name container diferent from the button is. Then add a colon at the beginning of the id and put it in the button update attribute (ie: `:nameContainer:menuPage`). Note: Use blank space instead comma or semicolon for separating updated areas. – Javier Haro Sep 24 '15 at 13:02

1 Answers1

-3

var name = "";
$.post("Path/To/Server/File", {'serverFileVariableName' : clientElementID},
       //data is what the server file will return
       function(data){
       //In this case, the data is the username.
       name = data;
       //invoke the show method to display 
       logOut.show();
}
);
//done