Jsf 通过actionListener以编程方式更改UIComponent样式无效

Jsf 通过actionListener以编程方式更改UIComponent样式无效,jsf,facelets,actionevent,Jsf,Facelets,Actionevent,在我的JSF项目中,我有一个带有多个commandlink的静态导航树,如: <h:commandLink id="navlinksearchperson" action="#{bean.someAction}" value="#{messages['menu.person']}" actionListener="#{styleBean.changeSelection}"

在我的JSF项目中,我有一个带有多个commandlink的静态导航树,如:

            <h:commandLink id="navlinksearchperson"
                action="#{bean.someAction}"
                value="#{messages['menu.person']}"
                actionListener="#{styleBean.changeSelection}">
            </h:commandLink>
我想要实现的是突出显示已单击的链接,以便用户准确地看到当前查看的导航链接/路径。将调用该事件,但未设置/呈现样式

我是否遗漏了什么,或者ActionEvent是否处于设置UIComponent属性的正确阶段

更新: 操作如下所示:

@RequestScoped
@Named("styleBean")
public class StyleBean {

    public void changeSelection(ActionEvent event) {
        if (event.getComponent() instanceof HtmlCommandLink) {
            ((HtmlCommandLink) event.getComponent()).setStyle("font-weight : bold; color : white");
        }
    }
}
public String init() {
    if (conversation.isTransient()) {
        conversation.begin();
    } 

    /*
     * Service call for request query
     */

    return "/views/list.xhtml";
}

如果操作正在重新创建视图而不是返回到同一视图(通过返回非
null
/
void
结果),则可能发生这种情况。@BalusC我已添加了我正在使用的操作。。。将返回视图ID。。。在这种情况下,对话有问题吗?