You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Dave Brondsema (JIRA)" <de...@myfaces.apache.org> on 2005/10/31 21:25:55 UTC
[jira] Created: (MYFACES-769) configurable IDs used for rendering
configurable IDs used for rendering
-----------------------------------
Key: MYFACES-769
URL: http://issues.apache.org/jira/browse/MYFACES-769
Project: MyFaces
Type: Improvement
Reporter: Dave Brondsema
If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Dave Brondsema (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12360269 ]
Dave Brondsema commented on MYFACES-769:
----------------------------------------
Okay. If my portlet does this:
<f:subview id="foo">
<!-- all my components -->
</f:subview>
And I use that portlet twice on one page, both instances of the portlet are using "foo" prefixes which doesn't help. (All lifecycle phases run fine since each instance is executed independently of the other, but the portal aggregates the HTML of instance 1, the HTML of instance 2, and some of its own HTML which makes forms and javascript not work)
I'd like to do something like this
<f:subview id="foo#{bean.random}">
<!-- all my components -->
</f:subview>
or (where render-id is a new attribute used only when rendering components):
<f:subview id="foo" render-id="foo#{bean.random}">
<!-- all my components -->
</f:subview>
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces
> Type: Improvement
> Reporter: Dave Brondsema
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Simon Kitching (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12360256 ]
Simon Kitching commented on MYFACES-769:
----------------------------------------
With non-portal JSP/JSF applications, including an external file multiple times is not an issue.
Suppose the included file has:
<h:inputText id="zzz"/>
The including page then does this:
<f:subview id="first">
<jsp:include page="include.jsp"/>
</f:subview>
<f:subview id="second">
<jsp:include page="include.jsp"/>
</f:subview>
This results in ids "first:zzz" and "second:zzz". Note that wrapping includes in f:subview is *required by the spec*, for exactly this reason.
However if all components in the included page have dynamic ids you can get away without using f:subview. If the included page is:
<h:inputText .. />
then the including page can do:
<jsp:include page="include.jsp"/>
<jsp:include page="include.jsp"/>
<jsp:include page="include.jsp"/>
resulting in components with ids _id0, _id1, _id2 respectively.
I don't know how this works with portlets, but I would assume that each portlet should be a "subview", thus ensuring the ids of its components don't conflict.
The f:subview works just like any old namespacing (filesystem, java package names, etc): you place names within parent namespaces to avoid name conflicts.
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces
> Type: Improvement
> Reporter: Dave Brondsema
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Martin Marinschek (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12365291 ]
Martin Marinschek commented on MYFACES-769:
-------------------------------------------
Before creating dynamic IDs, JSF calls the following:
ExternalContext extCtx = FacesContext.getCurrentInstance().getExternalContext();
return extCtx.encodeNamespace(UNIQUE_ID_PREFIX + _uniqueIdCounter++);
so you would basically need to make sure that the parent-most naming-container in your app has a dynamic id, and then make sure that your PortletExternalContextImpl overwrites that encodeNamespace method correctly.
Does that solve your problem?
regards,
Martin
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces
> Type: Improvement
> Reporter: Dave Brondsema
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Simon Kitching (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12360168 ]
Simon Kitching commented on MYFACES-769:
----------------------------------------
Please provide more details.
Is this problem specific to portlets, or does it affect traditional JSF apps too?
By "same code is used to generate a component tree" do you mean java code is used to create the components?
If so, that code is responsible for creating and setting unique ids on each component.
Or do you mean that the same JSP fragment is included into a page more than once, and the included fragment has defined explicit ids for the components using the "id" attribute? If so, wrapping the included component in an f:subview should ensure unique ids.
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces
> Type: Improvement
> Reporter: Dave Brondsema
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Dave Brondsema (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12368111 ]
Dave Brondsema commented on MYFACES-769:
----------------------------------------
In other words: My <h:form> is my parent-most naming container. I need its ID to be namespace-encoded since this portlet is used multiple times on the same portal page. Can I specify an id="foo" on the form and have that be namespace encoded? Or must the h:form use a dynamic id?
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces Core
> Type: Improvement
> Reporter: Dave Brondsema
> Assignee: Martin Marinschek
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Simon Kitching (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12360272 ]
Simon Kitching commented on MYFACES-769:
----------------------------------------
Your first example is why the f:subview should be *outside* the included file, as in my example.
And unfortunately JSF requires that "id" attributes be static text, not dynamic. That's because a component's id must never change over its lifetime.
As I know almost nothing at all about portlets, the following is just guesswork (and ignorant guesswork too :-)
>From your description I gather that each portlet is represented by a separate ViewRoot, and that the whole page is somehow composed by rendering each viewroot separately and stitching the results together. In this case, I presume that you can generate some kind of unique id string for each portlet that you are including in a page (including unique ids when the same portlet is included twice). So what I would do is ensure that id is included in the ids of the components by creating a custom UIViewRoot component.
The standard UIViewRoot class doesn't implement the NamingContainer interface, but I expect that if a custom one did, and its getClientId() method returns a unique "portlet" id then that portletId would become the prefix for every component in that portlet. The UIViewRoot is created via method ViewHandler.createView, and a simple config entry in your application's faces-config.xml file allows a custom ViewHandler to be specified.
I probably can't offer much more help on this as it's getting very portlet-specific now. Good luck!
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces
> Type: Improvement
> Reporter: Dave Brondsema
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Dave Brondsema (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12367734 ]
Dave Brondsema commented on MYFACES-769:
----------------------------------------
Namespaces are definitely the solution to this problem. Sorry I was in left field for a while until I realized this.
The portlet container I am using is providing a good namespace, and it is used in some components, but not others. It seems that when I specify the id on the component, it does not use the namespace, but when the id is automatically assigned it does use the namespace. This is of particular importance for my <h:form id="foo" ... > which renders as <form id="foo" name="foo" ...>
Why do I need to make sure that the parent-most naming-container in my app has a dynamic id?
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces Core
> Type: Improvement
> Reporter: Dave Brondsema
> Assignee: Martin Marinschek
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (MYFACES-769) configurable IDs used for rendering
Posted by "Dave Brondsema (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/MYFACES-769?page=comments#action_12360185 ]
Dave Brondsema commented on MYFACES-769:
----------------------------------------
Java code is not used to create the component tree, but that doesn't matter.
I don't know if it affects servlet JSF apps. Imagine a jsp file that is included twice on the same page. If the component ids are the same both times, then it is a problem. I suspect it is not.
Back to portlets. Whether ids are defined explicitly or not, the problem occurs. This is because the first time the portlet is run, the components have (for example) ids A, B, and C. When the portlet is displayed a second time on the page the components again have ids A, B, and C. The resulting aggregated HTML has A, B, and C twice. There needs to be a way to have dynamic ids for the rendered HTML.
I hope that made sense.
> configurable IDs used for rendering
> -----------------------------------
>
> Key: MYFACES-769
> URL: http://issues.apache.org/jira/browse/MYFACES-769
> Project: MyFaces
> Type: Improvement
> Reporter: Dave Brondsema
>
> If the same code is used ot generated a component tree for more than one part of a webpage, the rendered IDs are the same and functionality is broken (javascript needs unique IDs).
> An example of when this happens is when as portlet uses JSF for rendering. If the portlet is used more than once on a single page (e.g. an RSS reader) all the IDs are the same.
> Thus we need a way to have more configurable (perhaps random) IDs when rendered.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira