I'm actually doing this in an overridden getFirst() method. What I would like to be able to do is to allow getFirst() to make a decision, based upon the PaginationState, as to whether to return a custom first or to allow super.getFirst() to handle normally.
Would I need to use a PhaseListener to do this? Thanks, James -----Original Message----- From: Rhys Parry [mailto:[EMAIL PROTECTED] Sent: Wed 5/24/2006 1:38 PM To: MyFaces Discussion Subject: RE: Locating components by id James, Where are you doing this. Is it in the render response phase? Rhys -----Original Message----- From: James Richards [mailto:[EMAIL PROTECTED] Sent: May 24, 2006 1:25 PM To: [email protected] Subject: Locating components by id Hello, I am trying to implement a state mechanism similar to the "flowState" component described in "Taming JSF 1.1": http://bug.sakaiproject.org/confluence/pages/viewpage.action?pageId=4981 I have a PaginationState class: public class PaginationState extends UIComponentBase implements Serializable {...} which is configured as a component <component> <component-type>com.foo.faces.state.PaginationState</component-type> <component-class>com.foo.faces.state.PaginationState</component-class> </component> I would like to use this pagination state to coordinate paging of a custom HtmlDataTable extension: <component> <component-type>com.foo.faces.CustomPaginationHtmlDataTable</component-type> <component-class>com.foo.faces.component.CustomPaginationHtmlDataTable</component-class> </component> I declare the paginationState and custom table in the view which should exhibit the custom behavior: <foo:paginationState id="paginationState" bean="#{aForm}"/> <foo:customPaginationDataTable id="facilityLedgerData" styleClass="data" rowClasses="oddRow,evenRow" columnClasses="width125,width100,width100,width100,width100,width300,buttons" footerClass="footer" var="entry" rows="#{aForm.handler.rows}" value="#{aForm.model}" cellspacing="1" width="100%" preserveSort="true" rowIndexVar="index"> ... </foo:customPaginationDataTable> The custom table wants to override the "getFirst" property in cases where the paginationState is of a particular value. I am having trouble, however locating the UIComponent instances: public int getFirst() { System.out.println("Overriding getFirst(): state is " + paginationState); int fRwIdx = super.getFirst(); int rwCnt = super.getRowCount(); FacesContext ctx = FacesContext.getCurrentInstance(); UIViewRoot vwRt = ctx.getViewRoot(); List vwChld = vwRt.getChildren(); for(Iterator itr = vwChld.iterator(); itr.hasNext(); ) { UIComponent chld = (UIComponent)itr.next(); System.out.println("CHILD IS:" + chld.getId()); } PaginationState pgSt = (PaginationState)vwRt.findComponent(":paginationState"); if (pgSt == null) { System.out.println("NO PAGETODISPLAY COMPONENT"); } else { System.out.println("GOT PAGETODISPLAY COMPONENT:" + pgSt); System.out.println("HASVALUE:" + pgSt.getValueBinding("value").getValue(ctx)); System.out.println("HASBEAN:" + pgSt.getBean()); } if (rwCnt < BaseSearchHandler.DISPLAY_ROWS) { return super.getFirst(); } return getCustomFirstRow(); } In the above, I try to find paginationState from the UIViewRoot but am, so far, unable to locate it using either ":paginationState" or "paginationState". I can locate the managed bean upon which pagination state depends but not any of the defined view components. Is there any way in MyFaces to locate a particular UIComponent by ID? Thanks for any help, James
<<winmail.dat>>

