You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2006/01/13 01:10:51 UTC

[Myfaces Wiki] Trivial Update of "forceId" by SimonKitching

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by SimonKitching:
http://wiki.apache.org/myfaces/forceId

The comment on the change is:
Minor cleanups

------------------------------------------------------------------------------
  In particular, be very cautious about using forceId when also using Tiles. Every file needs to be aware of every other file that it might be combined with 
  in a single page, and must ensure that no forceId component it declares conflicts with a forceId component in any of those other files.
  
- === Avoiding forceId for javascript use ===
+ = Avoiding forceId for javascript use =
  
  Javascript "event handlers" attached to HTML elements can use the keyword "this" to access the DOM component that they are associated with. Example:
  {{{
@@ -101, +101 @@

  
  <h:inputText onchange="doSomething(this)"/>
  }}}
+ In some cases this information is sufficient to do away with any need to get the "id" of a component at all. 
+ 
- In some cases this information is sufficient to do away with any need to get the "id" of a component at all. Access from such an event handler to other components in the same page can often be done by using simple naming conventions. As an example, when an input component has JSF id attribute of "data", and its label has JSF id attribute of "dataLabel", a javascript event handler associated with the input component can get the label via:
+ Access from such an event handler to other components in the same page can often be done by using simple naming conventions. As an example, when an input component has JSF id attribute of "data", and its label has JSF id attribute of "dataLabel", a javascript event handler associated with the input component can get the label via:
  {{{
  var labelId = src.id + "Label";
  }}}
   
- Note that the id of the calling component will include the name of the nearest naming contaier (unless forceId has been used!). It is therefore simple to
+ Note that the id of the calling component will include the name of the nearest naming container (unless forceId has been used!). It is therefore simple to
  obtain ids for components within the same naming container without using forceId at all. Here's an example that allows one component to toggle the visibility
  of another component via javascript without needing to use forceId at all:
  {{{