Hi,

> This is i think your mistake:
> 
>     _tabbedPane = new HtmlPanelTabbedPane();
>     _tab = new HtmlPanelTab();
> 
> Never construct an UIComponent directly. It's lifecycle has to be
> managed by the JSF engine for things to work properly. If you need to
> create compoment using java code, use the application, like this:
> 
> Application application =
> FacesContext.getCurrentInstance().getApplication();
> _tabbedPane =
> (HtmlPanelTabbedPane)application.createComponent(HtmlPanelTabbedPane.COMPONENT_TYPE);

OK, makes sense, esp. because I already did that in other places.
So, I changed the code to:

public HtmlPanelTabbedPane getTabbedPane() {
  if (_tabbedPane == null) {
    Application app = FacesContext.getCurrentInstance().getApplication();
    _tabbedPane = 
(HtmlPanelTabbedPane)app.createComponent(HtmlPanelTabbedPane.COMPONENT_TYPE);
    _tab = (HtmlPanelTab)app.createComponent(HtmlPanelTab.COMPONENT_TYPE);
    _tab.setLabel("Blah");
    _tab.setId("PanelTab");
    _tabbedPane.getChildren().add(_tab);
    _tree = (HtmlTree)app.createComponent(HtmlTree.COMPONENT_TYPE);
....

But the behaviour did not change :-( Anything else suspicious?

TIA,
Uli

> Ulrich Teichert a écrit :
> > Hi,
> >
> >   
> >> Could you provide us with a sampel code of how you create your
> >> UIComponent?
> >>     
> >
> > Sure, I should have done that from the start. I also forgot to list
> > some vital version numbers - which proves that I couldn't really
> > think anymore yesterday evening...
> >
> > Anyway, I am using java 1.5 in a Linux environment, tomcat 5.0.28,
> > myfaces 1.1.5-SNAPSHOT, tomahawk-1.1.5-SNAPSHOT, spring 2.0RC1 and
> > tons of other stuff which is probably not that important.
> >
> > I'm creating my HtmlPanelTabbedPane on the fly in the get-method of
> > my bean, like this:
> >
> > public HtmlPanelTabbedPane getTabbedPane() {
> >   if (_tabbedPane == null) {
> >     _tabbedPane = new HtmlPanelTabbedPane();
> >     _tab = new HtmlPanelTab();
> >     _tab.setLabel("Blah");
> >     _tab.setId("PanelTab");
> >     _tabbedPane.getChildren().add(_tab);
> >     Application app =
> FacesContext.getCurrentInstance().getApplication();
> >     _tree = (HtmlTree)app.createComponent(HtmlTree.COMPONENT_TYPE);
> >     _tree.setClientSideToggle(false);
> >     _tree.setShowRootNode(true);
> >     _tree.setValueBinding("value",
> app.createValueBinding("#{myBean.treeModel}"));
> >     _tree.setVar("node");
> >     ValueBinding binding =
> app.createValueBinding("#{node.description}");
> >     HtmlOutputText text = new HtmlOutputText();
> >     text.setValueBinding("value", binding);
> >     _tree.getFacets().put("node", text);
> >     _tab.getChildren().add(_tree);
> >   }
> >   return _tabbedPane;
> > }
> >
> > As you can see, it's a stripped down example of what I want to do
> > in the end, currently I'm just creating one tab, but you get the
> > picture. There's a corresponding set-method, too.
> >
> > My template contains:
> >
> > <form jsfc="h:form" id="myMainForm">
> >   <h:panelGrid columns="2">
> >     <t:panelTabbedPane bgcolor="#CCFFFF" serverSideTabSwitch="true"
> binding="#{myBean.tabbedPane}">
> >     </t:panelTabbedPane>
> >     <h:panelGrid columns="1" binding="#{myBean.panelGrid}">
> >     </h:panelGrid>
> >   </h:panelGrid>
> > </form>
> >
> > As you can see, I have a panel grid as second element in my outer panel
> > grid, which is created roughly the same way:
> >
> > public HtmlPanelGrid getPanelGrid() {
> >   if (_panelGrid == null) {
> >   Application app = FacesContext.getCurrentInstance().getApplication();
> >   _panelGrid =
> (HtmlPanelGrid)app.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
> >   _panelGrid.setColumns(1);
> >   _panelGrid.setValueBinding("value",
> app.createValueBinding("#{myBean.panelGrid}"));
> > ....
> >   }
> >   return _panelGrid;
> > }
> >
> > But I don't think it's playing a vital role, I've just listed it here
> > so that the template makes sense to you. I have some HtmlInput stuff
> > in it, that's why I need the form.
> >
> > CU,
> > Uli
> >
> >   
> >> Ulrich Teichert a écrit :
> >>     
> >>> Hi,
> >>>
> >>> suppose I want to create some UIComponents via Java, which are not
> >>>       
> >> listed
> >>     
> >>> in any template (for instance, creating a variable number of tabs
> inside
> >>> a HtmlPanelTabbedPane).
> >>> These components will be added to an existing tabbed pane (generated
> >>> via a template from spring, to be exact).
> >>>
> >>> After some self-inflicted pain, I got them to show up just fine and my
> >>> data inside the tabs (org.apache.myfaces.custom.tree2.HtmlTree) is
> >>>       
> >> displayed, but after a save/restore cycle through going onto another
> page
> >>     
> >>> and coming back, nothing is there. I can see that I'm getting empty
> tabs
> >>> set during the process in my bean, but that's it.
> >>>
> >>> Maybe I'm just trying something stupid? Or do I need to implement
> >>>       
> >> another interface as "Serializable" as well in my bean? I would also
> happy for
> >>     
> >>> any hint where I should start debugging,
> >>>
> >>> thanks for any help,
> >>> Uli
> >>>   
> >>>       
> >
> >   

-- 
Ulrich Teichert
Stormweg 24
24539 Neumünster, Germany


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Reply via email to