JSF - change group panel with ajax calls - Beans, EL and?

I need to make some kind of switch of some panelGroupUI. In the browse section, I did the following:

<h:panelGroup layout="block" id="profile_content">
    <h:panelGroup layout="block" styleClass="content_title">
        Profilo Utente
    </h:panelGroup>

    <h:panelGroup rendered="#{selector.profile_page=='main'}">
        <ui:include src="/profile/profile_main.xhtml" />
    </h:panelGroup>

    <h:panelGroup rendered="#{selector.profile_page=='edit'}">
        <ui:include src="/profile/profile_edit.xhtml" />
    </h:panelGroup>

    <h:panelGroup rendered="#{selector.profile_page=='insert'}">
        <ui:include src="/profile/profile_articles.xhtml" />
    </h:panelGroup>
</h:panelGroup>

Now, to change this value, I wrote an exclusive JavaBean called Selector:

@ManagedBean(name="selector")
@RequestScoped
public class Selector {
    @ManagedProperty(value="#{param.profile_page}")
    private String profile_page;

    public String getProfile_page() {
        if(profile_page==null || profile_page.trim().isEmpty()) {
            this.profile_page="main";
        }
        return profile_page;
    }
    public void setProfile_page(String profile_page) { this.profile_page=profile_page; }
}

So, now my problem is solved: when I change the "context" with some h:commandButton, I would like to use an asynchronous call to the server. This is my button bar:

<h:commandButton value="EDIT">
    <f:ajax event="action" execute="???" render=":profile_content"/>
</h:commandButton>

<h:commandButton value="PM">
    <f:ajax event="action" execute="???" render=":profile_content"/>
</h:commandButton>

<h:commandButton value="ARTICLES">
    <f:ajax event="action" execute="???" render=":profile_content"/>
</h:commandButton>

I don’t know what to rely on execute, so I edit the Beans value and I change the context withrender=":profile_content"

I hope this question will be clear. Forgive me about the language :)

Greetings

+3
source share
1

f:setPropertyActionListener. f:ajax execute ( @this, ).

.

<h:commandButton value="EDIT">
    <f:setPropertyActionListener target="#{selector.profile_page}" value="edit" />
    <f:ajax event="action" render=":profile_content"/>
</h:commandButton>

, Java CamelCase under_score. profile_page profilePage. Java, PHP.

+2

Source: https://habr.com/ru/post/1776965/


All Articles