help with getClientId

Hi

I want to collect ClientId of another Component in the renderer of another.

index.jsp

<Custom component :tabbedpane>

<td>

<include navigation.jsp>

</td>

<Custom component :/tabbedpane>

navigation.jsp

-

<custom component :link>

</custom component :link>///here while rendering this component i need the clienId of TabbedPane.

--

[453 byte] By [sunnyjaina] at [2007-10-3 11:30:52]
# 1
Use the same ID as you set in the custom tabbedpane component. Or are those two different renderers? Use the UIViewRoot to find and retrieve the custom tabbedpane from.
BalusCa at 2007-7-15 13:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
i tried with UIViewRoot but was able to get the instance as i required .If u can provide me with a clear cut way of doing it
sunnyjaina at 2007-7-15 13:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Was you able or unable to get the component?Well, just iterate through the children of the UIViewRoot and check if there is an instance of your custom component.
BalusCa at 2007-7-15 13:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

No ,i was not able get what i wanted.

This is what i want in my navigation.jsp

"document.forms['" + formId + "']['" + clientId

+ "_default_workspace" + "'].value='"

+ default_workspace + "'; "

I am able to get formId but not able to get the clientId i.e ID of tabbedpane.

parent :com.corejsf.UINLink@148662//no childrens

parent :javax.faces.component.html.HtmlPanelGrid@1829e6f

List of Children :0 class com.corejsf.UINLink

parent :javax.faces.component.UINamingContainer@6fa9fc

List of Children :0 class javax.faces.component.html.HtmlPanelGrid

parent :javax.faces.component.UINamingContainer@100ebec

List of Children :0 class com.corejsf.UITabbedPane

List of Children :1 class javax.faces.component.UINamingContainer

//UINLink is my custom Link Component in navigation.jsp

If u can help me up with this .

sunnyjaina at 2007-7-15 13:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Well... if you were using JSFTemplating (https://jsftemplating.dev.java.net) this would be very easy. In your page you'd do:

<customComponentWithID ...>

<!afterCreate

setAttribute(key="theClientID", value="$this{clientId}");

/>

</customComponentWithID>

Then anywhere you need to use that client ID just refer to it with: #{theClientID}. You could use this to pass a property to a component, write it directly to the screen (i.e. for JavaScript), or passing it as an argument to Java code.

Without JSFTemplating, you will need to search the UIComponent tree *after* it has been created to find it. Your UINlink component can probably do this during beginEncode(). Start at the UIViewRoot and search the entire tree. Keep in mind this may fail for initial page displays in JSF 1.1 b/c the tree is not fully created before rendering (JSFTemplating solves this too).

Or you could use the "binding" attribute to manually create the component with the client ID you need... and store the value somewhere for later use. Be careful though b/c the component will not be parented unless you do that yourself... you may need to construct it yourself.

I hope this helps!

Good luck!

Ken Paulsen

https://jsftemplating.dev.java.net

KenPaulsena at 2007-7-15 13:57:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...