You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Travis Reeder <tr...@gmail.com> on 2005/11/19 00:11:06 UTC

Defaulting to forceId=true

Working on this ajax stuff, I got to wondering why we don't just have
id's implemented like forceId = true?  Is there any reason why we
can't just have all id's set to the id the user specifies without
prepending stuff to them?

Travis

Re: Defaulting to forceId=true

Posted by Simon Kitching <sk...@obsidium.com>.
Travis Reeder wrote:
> Working on this ajax stuff, I got to wondering why we don't just have
> id's implemented like forceId = true?  Is there any reason why we
> can't just have all id's set to the id the user specifies without
> prepending stuff to them?

The spec allows ids to be duplicated as long as they are in different 
naming containers.

In particular, it is possible to use

<f:subview>
   <jsp:include .../>
</f:subview>

and not worry whether any of the ids in the included page are the same 
as ids in the current page; a Subview is a naming container, so every 
component in the included page has the subview's id prefixed to it. That 
ensures that there are no id conflicts.

Prefixing ids with the enclosing naming container's id is also critical 
in tables (a table is a naming container which pretends to have a 
different id as its rowIndex changes, so that component in different 
rows have different prefixes to distinguish them.

Regards,

Simon

Re: Defaulting to forceId=true

Posted by Travis Reeder <tr...@gmail.com>.
There are a couple reasons I went down that road,

1: at first, when trying to get things working, it was much easier to
be able to directly access the component in javascript. I wanted to
get this working without having to deal with unknown id's, and then
come back to get it working for those cases.
2: If you reference the components in javascript by their derived id,
for example:
var component_form1:subview2:table3, javascript pukes, as would java
or any other languages.  This could be avoided I'm sure, but it was
something that was occuring.
3: I have to make it work for forceId anyways so that I can access the
components from javascript in a deterministic way.

Travis


On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> Hi Travis,
>
> I don't know anything about the AJAX compoents so please excuse me if
> this is a silly question. But why are the AJAX components requiring
> "forceId" in the first place?
>
> If a component's true id at the back end is "form1:subview2:table3",
> then why not use that id in all the AJAX stuff rather than requiring the
> table to use forceId?
>
> Travis Reeder wrote:
> > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > (about altering the id), if I set an ID, it would be nice to not have
> > to set forceId="true" also.  Especially in this new rich client /
> > ajaxing era that we seem to be rolling into.
>

Re: Defaulting to forceId=true

Posted by Travis Reeder <tr...@gmail.com>.
> Well, if Simon's point is that Ajax should not *require* forceId then
> I agree with him (or whoever is making that point.)  We're not
> requiring it right now but I think that is what Travis is suggesting
> (with the reasoning be that you almost always want to use it anyways.)

I'm not suggesting that you have to use forceId, I'm suggesting (or
rather asking for opinions) that it would be nice to have a rendered
id that is actually the id I specified without having to use forceId. 
Forget about AJAX, just in general.

As for the AJAX stuff, just to clear things up, I have no intention of
making it so forceId is required.

Travis

On 11/23/05, Martin Marinschek <ma...@gmail.com> wrote:
> Right.
>
> I would never, ever want to force users to use forceId for working with AJAX.
>
> So, my opinion is on record ;)
>
> regards,
>
> Martin
>
> On 11/24/05, Sean Schofield <se...@gmail.com> wrote:
> > Well, if Simon's point is that Ajax should not *require* forceId then
> > I agree with him (or whoever is making that point.)  We're not
> > requiring it right now but I think that is what Travis is suggesting
> > (with the reasoning be that you almost always want to use it anyways.)
> >
> > As for why you would *ever* want to use it with Ajax, I think Martin
> > and I were answering that question.  The reasoning doesn't change.
> >
> > sean
> >
> > On 11/23/05, Adam Winer <aw...@gmail.com> wrote:
> > > I think Simon's question is not about why "forceId" exists
> > > in the first place, but why AJAX would *require* its use.
> > >
> > > The former was discussed long ago.  The latter is a new
> > > question which deserves careful consideration.
> > >
> > > -- Adam
> > >
> > >
> > > On 11/23/05, Sean Schofield <se...@gmail.com> wrote:
> > > > Simon,
> > > >
> > > > There are a few very long threads on this in the archives (when
> > > > forceId first came about.)  Not only is it awkward to add
> > > > "form1:subview2" etc to every reference in your javascript but if you
> > > > change your JSF form structure all of your javascript needs to change
> > > > too!  (NOTE: Its not always practical to have your component generate
> > > > your javascript.)
> > > >
> > > > Again, see the archived discussions for more on the reasoning.  It was
> > > > a pretty lively debate with lots of good points raised on all sides.
> > > >
> > > > sean
> > > >
> > > > On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> > > > > Hi Travis,
> > > > >
> > > > > I don't know anything about the AJAX compoents so please excuse me if
> > > > > this is a silly question. But why are the AJAX components requiring
> > > > > "forceId" in the first place?
> > > > >
> > > > > If a component's true id at the back end is "form1:subview2:table3",
> > > > > then why not use that id in all the AJAX stuff rather than requiring the
> > > > > table to use forceId?
> > > > >
> > > > > Travis Reeder wrote:
> > > > > > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > > > > > (about altering the id), if I set an ID, it would be nice to not have
> > > > > > to set forceId="true" also.  Especially in this new rich client /
> > > > > > ajaxing era that we seem to be rolling into.
> > > > >
> > > >
> > >
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>

Re: Defaulting to forceId=true

Posted by Martin Marinschek <ma...@gmail.com>.
Right.

I would never, ever want to force users to use forceId for working with AJAX.

So, my opinion is on record ;)

regards,

Martin

On 11/24/05, Sean Schofield <se...@gmail.com> wrote:
> Well, if Simon's point is that Ajax should not *require* forceId then
> I agree with him (or whoever is making that point.)  We're not
> requiring it right now but I think that is what Travis is suggesting
> (with the reasoning be that you almost always want to use it anyways.)
>
> As for why you would *ever* want to use it with Ajax, I think Martin
> and I were answering that question.  The reasoning doesn't change.
>
> sean
>
> On 11/23/05, Adam Winer <aw...@gmail.com> wrote:
> > I think Simon's question is not about why "forceId" exists
> > in the first place, but why AJAX would *require* its use.
> >
> > The former was discussed long ago.  The latter is a new
> > question which deserves careful consideration.
> >
> > -- Adam
> >
> >
> > On 11/23/05, Sean Schofield <se...@gmail.com> wrote:
> > > Simon,
> > >
> > > There are a few very long threads on this in the archives (when
> > > forceId first came about.)  Not only is it awkward to add
> > > "form1:subview2" etc to every reference in your javascript but if you
> > > change your JSF form structure all of your javascript needs to change
> > > too!  (NOTE: Its not always practical to have your component generate
> > > your javascript.)
> > >
> > > Again, see the archived discussions for more on the reasoning.  It was
> > > a pretty lively debate with lots of good points raised on all sides.
> > >
> > > sean
> > >
> > > On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> > > > Hi Travis,
> > > >
> > > > I don't know anything about the AJAX compoents so please excuse me if
> > > > this is a silly question. But why are the AJAX components requiring
> > > > "forceId" in the first place?
> > > >
> > > > If a component's true id at the back end is "form1:subview2:table3",
> > > > then why not use that id in all the AJAX stuff rather than requiring the
> > > > table to use forceId?
> > > >
> > > > Travis Reeder wrote:
> > > > > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > > > > (about altering the id), if I set an ID, it would be nice to not have
> > > > > to set forceId="true" also.  Especially in this new rich client /
> > > > > ajaxing era that we seem to be rolling into.
> > > >
> > >
> >
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Defaulting to forceId=true

Posted by Sean Schofield <se...@gmail.com>.
Well, if Simon's point is that Ajax should not *require* forceId then
I agree with him (or whoever is making that point.)  We're not
requiring it right now but I think that is what Travis is suggesting
(with the reasoning be that you almost always want to use it anyways.)

As for why you would *ever* want to use it with Ajax, I think Martin
and I were answering that question.  The reasoning doesn't change.

sean

On 11/23/05, Adam Winer <aw...@gmail.com> wrote:
> I think Simon's question is not about why "forceId" exists
> in the first place, but why AJAX would *require* its use.
>
> The former was discussed long ago.  The latter is a new
> question which deserves careful consideration.
>
> -- Adam
>
>
> On 11/23/05, Sean Schofield <se...@gmail.com> wrote:
> > Simon,
> >
> > There are a few very long threads on this in the archives (when
> > forceId first came about.)  Not only is it awkward to add
> > "form1:subview2" etc to every reference in your javascript but if you
> > change your JSF form structure all of your javascript needs to change
> > too!  (NOTE: Its not always practical to have your component generate
> > your javascript.)
> >
> > Again, see the archived discussions for more on the reasoning.  It was
> > a pretty lively debate with lots of good points raised on all sides.
> >
> > sean
> >
> > On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> > > Hi Travis,
> > >
> > > I don't know anything about the AJAX compoents so please excuse me if
> > > this is a silly question. But why are the AJAX components requiring
> > > "forceId" in the first place?
> > >
> > > If a component's true id at the back end is "form1:subview2:table3",
> > > then why not use that id in all the AJAX stuff rather than requiring the
> > > table to use forceId?
> > >
> > > Travis Reeder wrote:
> > > > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > > > (about altering the id), if I set an ID, it would be nice to not have
> > > > to set forceId="true" also.  Especially in this new rich client /
> > > > ajaxing era that we seem to be rolling into.
> > >
> >
>

AJAX and ids (was Defaulting to forceId=true)

Posted by Simon Kitching <sk...@obsidium.com>.
I haven't used AJAX, but isn't the javascript concerned *generated* by 
JSF tags? If so, the generated javascript should be able to create
   document.getElementById("form1:subview2:button1")

Or is it that AJAX is commonly combined with user-provided javascript 
that manipulates the same DOM components in the page? If so, then how 
about providing some kind of bridge between the two worlds rather than 
forcing JSF to use non-nested ids. Here's a proposal off the top of my head:
   <t:ajaxInputText ajaxId="foo"/>
   <t:axajInputText ajaxId="bar"/>
causes this to be emitted into the page to map convenient names for user 
scripts through to the real JSF ids.
  <script>
  var AJAX = new Object();
  AJAX.foo = document.getElementById("form1:subview2:foo");
  AJAX.bar = document.getElementById("form2:subview2:bar");
  </script>
User code can then use:
   AJAX.foo
rather than
   document.foo
while JSF ids are completely unaffected.

Of course there are probably good reasons against this which were 
pointed out in the ajax thread that I haven't found time to read yet. 
Sorry if this is the case.

Cheers,

Simon

Adam Winer wrote:
> I think Simon's question is not about why "forceId" exists
> in the first place, but why AJAX would *require* its use.
> 
> The former was discussed long ago.  The latter is a new
> question which deserves careful consideration.
> 
> -- Adam
> 
> 
> On 11/23/05, Sean Schofield <se...@gmail.com> wrote:
>> Simon,
>>
>> There are a few very long threads on this in the archives (when
>> forceId first came about.)  Not only is it awkward to add
>> "form1:subview2" etc to every reference in your javascript but if you
>> change your JSF form structure all of your javascript needs to change
>> too!  (NOTE: Its not always practical to have your component generate
>> your javascript.)
>>
>> Again, see the archived discussions for more on the reasoning.  It was
>> a pretty lively debate with lots of good points raised on all sides.
>>
>> sean
>>
>> On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
>>> Hi Travis,
>>>
>>> I don't know anything about the AJAX compoents so please excuse me if
>>> this is a silly question. But why are the AJAX components requiring
>>> "forceId" in the first place?
>>>
>>> If a component's true id at the back end is "form1:subview2:table3",
>>> then why not use that id in all the AJAX stuff rather than requiring the
>>> table to use forceId?
>>>
>>> Travis Reeder wrote:
>>>> Yes, I can use forceId=true when I want it, but my sentiments exactly
>>>> (about altering the id), if I set an ID, it would be nice to not have
>>>> to set forceId="true" also.  Especially in this new rich client /
>>>> ajaxing era that we seem to be rolling into.
> 


Re: Defaulting to forceId=true

Posted by Adam Winer <aw...@gmail.com>.
I think Simon's question is not about why "forceId" exists
in the first place, but why AJAX would *require* its use.

The former was discussed long ago.  The latter is a new
question which deserves careful consideration.

-- Adam


On 11/23/05, Sean Schofield <se...@gmail.com> wrote:
> Simon,
>
> There are a few very long threads on this in the archives (when
> forceId first came about.)  Not only is it awkward to add
> "form1:subview2" etc to every reference in your javascript but if you
> change your JSF form structure all of your javascript needs to change
> too!  (NOTE: Its not always practical to have your component generate
> your javascript.)
>
> Again, see the archived discussions for more on the reasoning.  It was
> a pretty lively debate with lots of good points raised on all sides.
>
> sean
>
> On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> > Hi Travis,
> >
> > I don't know anything about the AJAX compoents so please excuse me if
> > this is a silly question. But why are the AJAX components requiring
> > "forceId" in the first place?
> >
> > If a component's true id at the back end is "form1:subview2:table3",
> > then why not use that id in all the AJAX stuff rather than requiring the
> > table to use forceId?
> >
> > Travis Reeder wrote:
> > > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > > (about altering the id), if I set an ID, it would be nice to not have
> > > to set forceId="true" also.  Especially in this new rich client /
> > > ajaxing era that we seem to be rolling into.
> >
>

Re: Defaulting to forceId=true

Posted by Martin Marinschek <ma...@gmail.com>.
Additionally,

the colon is a reserved character in CSS - for pseudo-selectors. You
can run into major problems with CSS and the standard client-ids.

regards,

Martin

On 11/23/05, Sean Schofield <se...@gmail.com> wrote:
> Simon,
>
> There are a few very long threads on this in the archives (when
> forceId first came about.)  Not only is it awkward to add
> "form1:subview2" etc to every reference in your javascript but if you
> change your JSF form structure all of your javascript needs to change
> too!  (NOTE: Its not always practical to have your component generate
> your javascript.)
>
> Again, see the archived discussions for more on the reasoning.  It was
> a pretty lively debate with lots of good points raised on all sides.
>
> sean
>
> On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> > Hi Travis,
> >
> > I don't know anything about the AJAX compoents so please excuse me if
> > this is a silly question. But why are the AJAX components requiring
> > "forceId" in the first place?
> >
> > If a component's true id at the back end is "form1:subview2:table3",
> > then why not use that id in all the AJAX stuff rather than requiring the
> > table to use forceId?
> >
> > Travis Reeder wrote:
> > > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > > (about altering the id), if I set an ID, it would be nice to not have
> > > to set forceId="true" also.  Especially in this new rich client /
> > > ajaxing era that we seem to be rolling into.
> >
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Defaulting to forceId=true

Posted by Sean Schofield <se...@gmail.com>.
Simon,

There are a few very long threads on this in the archives (when
forceId first came about.)  Not only is it awkward to add
"form1:subview2" etc to every reference in your javascript but if you
change your JSF form structure all of your javascript needs to change
too!  (NOTE: Its not always practical to have your component generate
your javascript.)

Again, see the archived discussions for more on the reasoning.  It was
a pretty lively debate with lots of good points raised on all sides.

sean

On 11/22/05, Simon Kitching <sk...@obsidium.com> wrote:
> Hi Travis,
>
> I don't know anything about the AJAX compoents so please excuse me if
> this is a silly question. But why are the AJAX components requiring
> "forceId" in the first place?
>
> If a component's true id at the back end is "form1:subview2:table3",
> then why not use that id in all the AJAX stuff rather than requiring the
> table to use forceId?
>
> Travis Reeder wrote:
> > Yes, I can use forceId=true when I want it, but my sentiments exactly
> > (about altering the id), if I set an ID, it would be nice to not have
> > to set forceId="true" also.  Especially in this new rich client /
> > ajaxing era that we seem to be rolling into.
>

Re: Defaulting to forceId=true

Posted by Simon Kitching <sk...@obsidium.com>.
Hi Travis,

I don't know anything about the AJAX compoents so please excuse me if 
this is a silly question. But why are the AJAX components requiring 
"forceId" in the first place?

If a component's true id at the back end is "form1:subview2:table3", 
then why not use that id in all the AJAX stuff rather than requiring the 
table to use forceId?

Travis Reeder wrote:
> Yes, I can use forceId=true when I want it, but my sentiments exactly
> (about altering the id), if I set an ID, it would be nice to not have
> to set forceId="true" also.  Especially in this new rich client /
> ajaxing era that we seem to be rolling into.

Re: Defaulting to forceId=true

Posted by Travis Reeder <tr...@gmail.com>.
Yes, I can use forceId=true when I want it, but my sentiments exactly
(about altering the id), if I set an ID, it would be nice to not have
to set forceId="true" also.  Especially in this new rich client /
ajaxing era that we seem to be rolling into.

Thanks for the info on what's going on Adam.

Travis

On 11/22/05, Adam Winer <aw...@gmail.com> wrote:
> Sean,
>
> IMO, the lamenesses are that UIForm is a NamingContainer,
> and <f:subview> is required for includes.  I argued strongly
> against the former during JSF 1.0, but couldn't turn the tide.
> The latter's been cleared up for JSF 1.2 (and despite what
> the spec said, <f:subview> wasn't ever *really* required),
> and prefixing can be turned of for UIForms too in JSF 1.2.
>
> Subtract these two issues, and "forceId" isn't especially
> necessary or useful.
>
> Regards,
> Adam
>
>
> On 11/22/05, Sean Schofield <se...@gmail.com> wrote:
> > Is there any particular reason why you can't just use forceId=true for
> > when you want it?  My thinking is that its better to give the user the
> > flexability to decide rather then "force" them into a particular
> > choice.  (Which is why I think its lame that JSF alters your id when
> > generating the client id.)
> >
> > sean
> >
> > On 11/18/05, Travis Reeder <tr...@gmail.com> wrote:
> > > Working on this ajax stuff, I got to wondering why we don't just have
> > > id's implemented like forceId = true?  Is there any reason why we
> > > can't just have all id's set to the id the user specifies without
> > > prepending stuff to them?
> > >
> > > Travis
> > >
> >
>

Re: Defaulting to forceId=true

Posted by Adam Winer <aw...@gmail.com>.
Sean,

IMO, the lamenesses are that UIForm is a NamingContainer,
and <f:subview> is required for includes.  I argued strongly
against the former during JSF 1.0, but couldn't turn the tide.
The latter's been cleared up for JSF 1.2 (and despite what
the spec said, <f:subview> wasn't ever *really* required),
and prefixing can be turned of for UIForms too in JSF 1.2.

Subtract these two issues, and "forceId" isn't especially
necessary or useful.

Regards,
Adam


On 11/22/05, Sean Schofield <se...@gmail.com> wrote:
> Is there any particular reason why you can't just use forceId=true for
> when you want it?  My thinking is that its better to give the user the
> flexability to decide rather then "force" them into a particular
> choice.  (Which is why I think its lame that JSF alters your id when
> generating the client id.)
>
> sean
>
> On 11/18/05, Travis Reeder <tr...@gmail.com> wrote:
> > Working on this ajax stuff, I got to wondering why we don't just have
> > id's implemented like forceId = true?  Is there any reason why we
> > can't just have all id's set to the id the user specifies without
> > prepending stuff to them?
> >
> > Travis
> >
>

Re: Defaulting to forceId=true

Posted by Sean Schofield <se...@gmail.com>.
Is there any particular reason why you can't just use forceId=true for
when you want it?  My thinking is that its better to give the user the
flexability to decide rather then "force" them into a particular
choice.  (Which is why I think its lame that JSF alters your id when
generating the client id.)

sean

On 11/18/05, Travis Reeder <tr...@gmail.com> wrote:
> Working on this ajax stuff, I got to wondering why we don't just have
> id's implemented like forceId = true?  Is there any reason why we
> can't just have all id's set to the id the user specifies without
> prepending stuff to them?
>
> Travis
>