Hi Jeremy,
your conclusion is absolutely right. The getter of the method-binding
will only be called once - then the component is recreated from the
saved state, and will not be created by calling your getter.
You'll understand this if you think about the state saving feature of
JSF - if you would be able to provide a new component at every
request, how would the state saving ever work?
If you want to change your component, you'll need to provide a
_setter_ for the component, and do the modifications there or in an
action-method (which runs after the setter for the component has been
called, so you can access the actual JSF component there). The setter
will be called on every request!
regards,
Martin
On 12/19/05, Jeremy Sager <[EMAIL PROTECTED]> wrote:
>
>
>
> Hey guys –
>
>
>
> Thanks in advance for your help.
>
>
>
> I have a panelTabbedPane that I am binding directly to a bean so that I can
> create the pane programmatically.
>
>
>
> Here is the tag definition:
>
>
>
> <t:panelTabbedPane binding="#{editorPanelBean.pane}"/>
>
>
>
> Now, in my bean, I have the getPane() method… I have included the entire
> class file here (don't worry, it's not big) except for the package and
> import declarations. The IEditorPanelTabBean list can be safely ignored,
> it's not being used.
>
>
>
>
>
> /**
>
> * @jsf.bean name="editorPanelBean" scope="session"
>
> */
>
> public class EditorPanelBean {
>
>
>
> private ArrayList<IEditorPanelTabBean> tabs = new
> ArrayList<IEditorPanelTabBean>();
>
>
>
> private String TABBEDPANE =
> "org.apache.myfaces.HtmlPanelTabbedPane";
>
> private String PANELTAB = "org.apache.myfaces.HtmlPanelTab";
>
>
>
> //private String TABBEDPANE =
> HtmlPanelTabbedPane.class.getName();
>
> //private String PANELTAB = HtmlPanelTab.class.getName();
>
>
>
> private UIComponent pane = null;
>
> private HtmlPanelTab tab = null;
>
>
>
> private int numtimes = 0;
>
>
>
> public UIComponent getPane (){
>
> FacesContext context = FacesContext.getCurrentInstance();
>
> Application app = context.getApplication();
>
>
>
> if (pane == null){
>
> pane = app.createComponent(TABBEDPANE);
>
> }
>
>
>
> if (tab == null){
>
> tab = (HtmlPanelTab)app.createComponent(PANELTAB);
>
> }
>
>
>
> numtimes ++;
>
> System.out.println("Numtimes = " + numtimes);
>
> tab.setLabel(Integer.toString(numtimes));
>
>
>
> pane.getChildren().add(tab);
>
>
>
> return pane;
>
> }
>
>
>
> }
>
>
>
> Now, as you can see, it should be printing out to the console the value of
> numtimes.
>
>
>
> When the page first loads, everything goes as expected. However, if I hit
> the refresh button in my browser, nothing prints out to the console, and it
> never hits the method in Eclipse's debug mode (which it does on initial
> load).
>
>
>
> I have another tag, for a table, whose data is backed by a bean on the same
> page (not the same jsp, but they are both imported by another "container"
> page).
>
>
>
> <h:dataTable value="#{todoHandler.todoListModel}" var="list"
>
> first="#{todoHandler.firstRowIndex}"
>
> rows="#{todoHandler.noOfRows}"
>
> styleClass="view" rowClasses="tableRow">
>
>
>
>
>
> Now, the method ToDoHandler.getNoOfRows also has a sysout, which DOES print
> to the console every time I refresh the page, so I know it's not that I'm
> just getting some cached version or that my browser is bugging out.
>
>
>
> They are both session level beans as you can see:
>
>
>
>
>
> <managed-bean>
>
> <managed-bean-name>todoHandler</managed-bean-name>
>
> <managed-bean-class>(name
> omitted).ToDoListHandler</managed-bean-class>
>
> <managed-bean-scope>session</managed-bean-scope>
>
> </managed-bean>
>
>
>
> <managed-bean>
>
> <managed-bean-name>editorPanelBean</managed-bean-name>
>
> <managed-bean-class>(name
> omitted).EditorPanelBean</managed-bean-class>
>
> <managed-bean-scope>session</managed-bean-scope>
>
> </managed-bean>
>
>
>
>
>
> So… what gives? Does the component binding not refresh when the page is
> reloaded, but the value binding does? I know this is a lot of information,
> but I'd rather give too much than too little, and I appreciate any help I
> can get as this has turned into a total blocker issue for me.
>
>
>
>
> Jeremy Sager
>
> Data Communications Product Manager
>
> Chesapeake System Solutions
>
> 410.356.6805 x120
>
>
> [EMAIL PROTECTED]
>
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces