Updating UIComponent from Java code (Bean)

UI Components for JSF
Post Reply
BMWTouring
Posts: 7
Joined: 14 Nov 2010, 11:52

05 Nov 2011, 22:09

I have a ManagedBean which is handling a:

Code: Select all

public void valueChangeMethod(ValueChangeEvent event)
In this Java code I want to set the disabled property in Java from a Tab. The status is working (is changed) but it does not show on the cliënt side. In Swing this was also a problem.

How do I update my UI Component Tree from within Java?? My scopes are @RequestScoped

Code: Select all

FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Sample info message", newValue));
       
        UIComponent uicomp = UIComponent.getCurrentComponent(fc);
        
        
        TabView tabview = (TabView) uicomp.findComponent("tabview");

        
        Tab tabone = (Tab) tabview.findComponent("tabone");
        
        if (roken != null)
        {
        if (newValue.equalsIgnoreCase("ja"))
        {
            tabone .setDisabled(false);
            tabone .setTitle(newValue);
            
        }
        else
        {
            tabone .setDisabled(true);
        }
                   
        System.out.println("Aan: "+tabone .isDisabled());
        }

User avatar
kataras
Posts: 42
Joined: 12 Apr 2011, 21:51
Location: Xanthi/Greece
Contact:

05 Nov 2011, 22:28

just make it with a property on your bean named : boolean tab1disabled = false;
boolean tab2disabled=false;
String tab1title="Tab 1"; String tab2title="Tab 2"; ( do getters-setters too ) and e.t.c ..

and on ur view's xhtml file , on tab make : disabled=#{yourBean.isTab1Disabled}

and on your managedBean's void valueChange , make :

if (newValue.equalsIgnoreCase("ja"))
{
setTab1Disabled(false);
setTab1title(newValue);

}
else
{
setTab1Disabled(true);
}
PrimeFaces 3.0 RC1 version . Netbeans 7.0.1 . Apache Tomcat 7.0.22 . Firefox 7.0.1 & Google Chrome ,
Mandriva 2011 & Windows Home Server 2011 & Windows 8 Developer Preview .

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 10 guests