I also dislike the "forceId" function. It's not a good solution IMHO,
because it merges the concepts of HTML ids and JSF ids, thus losing the
abiility to safely compose pages from JSF fragments.

I have been vaguely thinking about solutions for this, esp. as the AJAX
components seem to currently be heavily dependent on the forceId. The
idea isn't completely thought through, but as the thread is currently on
discussion I'll toss it out there for consideration.

How about creating a new tomahawk component t:jsid:
  <h:form id="theForm">
    <h:inputText id="theInput" value="#{bean.inputValue}"/>
    <t:jsid for="theInput" obj="jsIds" id="myInputComponent"/>
  </h:form>

Where the t:jsid component's rendering simply stores away a reference to
the component in the current request. At page end (just before </html>)
the following is then output:

<script>
  var jsIds = new Object();
  jsIds.myInputComponent = document.getElementById('theForm:theInput');
  // repeat above line for each t:jsId component
</script>

Javascript can then access any JSF component which has an associated
t:jsid component like:
  jsIds.myInputComponent = "some-value";

Regards,

Simon

On Fri, 2006-01-06 at 11:50 -0500, Marti, Adrian (Adrian) wrote:
> Thanks for the replies everyone, appreciate it. I'll probably try and go
> with the tomahawk components for now. 
> 
> Adrian
> 
> -----Original Message-----
> From: Sean Schofield [mailto:[EMAIL PROTECTED] 
> Sent: Friday, January 06, 2006 11:43 AM
> To: MyFaces Discussion
> Subject: Re: Something like forceId for regular components?
> 
> Volker,
> 
> One issue is that not all javascript is created by your components. 
> Especially when migrating an existing application.
> 
> There was a very long (and IMO interesting) discussion about this
> forceId issue a little over a year ago.  If you check the archives[1]
> you can see some of the arguments that were made on both sides of the
> issue.
> 
> Sean
> 
> [1] http://www.mail-archive.com/[email protected]/msg00680.html
> 
> 
> On 1/6/06, Volker Weber <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > can't you use these created ids in you javascript?
> >
> > If you set a id to the form component, and to all other
> namingContainer
> > components, you will get defined ids for all your components and can
> > work with them in your scripts.
> >
> > IMHO forceId makes more problems than it solves.
> >
> > Regards
> >   Volker
> >
> > Marti, Adrian (Adrian) wrote:
> > > Hello all,
> > >
> > >
> > >
> > > First post, hopefully not too common a question.
> > >
> > >
> > >
> > >
> > >
> > >             Working on a project with a lot of preexisting
> javascript
> > > functions where the id's of components need to be exactly what is
> > > expected. JSF seems to want to prefix all of my component id's with
> the
> > > form id.
> > >
> > >
> > >
> > >             Such as
> > >
> > >                         <h:form id="acctform">
> > >
> > >
> > >
> > >                         <h:inputText id="firstInput"   ... />
> > >
> > >                         ... </h:form>
> > >
> > >
> > >
> > >             Will show up in the html with an
> id="acctform:firstInput".
> > > This obviously breaks the javascript. I have found the forceId
> attribute
> > > for Tomahawk components but haven't seen anything for the regular
> > > components. Anyone have any advice?
> > >
> > >
> > >
> > >
> > >
> > > Thanks,
> > >
> > > Adrian
> > >
> > >
> > >
> > >
> > >
> >
> > --
> > Don't answer to From: address!
> > Mail to this account are droped if not recieved via mailinglist.
> > To contact me direct create the mail address by
> > concatenating my forename to my senders domain.
> >
> 

Reply via email to