Re: Dynamically refer to a component from another component

2006-01-20 Thread Enrique Medina
Hi Simon,Yes, that was exactly the point. It's as easy as adding all the children, and at the end of the tree component creation, call to getClientId().Thanks a lot for your support.
2006/1/19, Simon Kitching [EMAIL PROTECTED]:
I believe Volker's answer is exactly what you're looking for. UnlessI've misunderstood your question, method getClientId is what you want;you just need to make sure the component is attached to the view treebefore calling that method.
ie:UIOutput texto4 = createComponent(..);texto4.setId(texto4);// parent is expected to already be attached to the view tree.parent.getChildren().add(texto4);// do this only after adding to view tree. You'll then get the
// full final id of the component, eg form1:subview1:table3:texto4String texto4ClientId = texto4.getClientId(facesContext);// use texto4ClientId in _javascript_ emitted for some other component
If you need to find the texto4 client from some other renderer, youcan search for it:UIOutput text05 = createComponent(..);// find a component with the specified name within the same
// naming container as the component the find is invoked onUIOutput targetComponent = parent.findComponent(texto4);String targetClientId = targetComponent.getClientId();// use targetClientId in _javascript_ emitted for texto5 component
Note also that component ids starting with underscores are reserved forthe use of the JSF framework; any id you assign explicitly should *not*start with an underscore.Regards,Simon
On Thu, 2006-01-19 at 16:49 +0100, Enrique Medina wrote: See what is generated at runtime: input id=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input name=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input type=
 text value=12 > class=txt / And obviously, a component with _input ID does not exist, because as
 being contained, the ID generated for the input component is different... 2006/1/19, Volker Weber [EMAIL PROTECTED]
: Hi, you can get the rendered 'htmlId' of a component by component.getCientId(facesContext); so you can do : UIOutput texto5 = (HtmlOutputText)
 FacesUtils.getApplication().createComponent( HtmlOutputText.COMPONENT_TYPE); texto5.getAttributes().put(onclick, validate(' + 
texto4.getClientId(facesContext) + ')); Regards, Volker Enrique Medina wrote:  Also I forgot to say, that if I wanted to use the onclick
 method on the  same UIInput component, I could define it easily by:  texto4.getAttributes().put(onclick, validate( 
this.value));   As you can see, I know that 'this' refers to my component. But what  happens if I need to refer to texto4 component value from
 another  component. Imagine:   UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication()  .createComponent(
HtmlOutputText.COMPONENT_TYPE);   texto5.getAttributes().put(onclick, validate(XX));   where XX is a _javascript_ reference to the value of
 texto4.2006/1/19, Enrique Medina [EMAIL PROTECTED]  mailto: 
[EMAIL PROTECTED]:   Let me give a more detailed explanation of what I am trying to achieve.. 
  In my application I need to work with data in a spreadsheet form, so  I decided to use a PanelTabbed component, where each tab would  contain a HtmlDataTable. All these would simulate an
 Excel page,  where I can change the actual tab, make some modifications to the  elements in the table, go to another tab, modify, etc, so at the end
  I would press the save button, and all the changes would be  persisted to the DB.   The big problem I had with defining this page was the
 fact that all  the data that was used to populate the tables in each tab was not  known at compile time, as it depended on the values entered by the
  user during the normal use of the application.   So I had to create all the components dynamically through Java code.  To accomplish this objective, I created a JSP file with
 simply a  PanelTabbed tag that I binded to a property in my backing bean, so  whenever JSF called my setBindedTabbedPane method, I could create
  all the tabs, tables, labels, inputs, etc, in code.   Once done, everything was perfect, in the sense that my application  was implemented to dynamically create all the components
 needed to  simulate an Excel worksheet; i.e. dynamic number of columns and  rows, dynamic number of tabs, etc.   On the other hand, I have also added DWR to my
 application in order  to use Ajax for particular purposes, like showing child data in a  datatable, or simply validate some specific fields
 without having to  make a JSF request. So I decided to add a DWR Ajax validate process  to my recently created Excel worksheet. 
  But the problem comes because when using DWR Ajax, I need to define  a callback function in _javascript_ where I have to pass as a  parameter the value that I want to be validated. As you
 already  know, I am generating all the components dynamically in code, within  a loop that reuses temporal variable names for the sake of
  performance and clearness. This means that I use the  

Re: Dynamically refer to a component from another component

2006-01-20 Thread Enrique Medina
I have been implementing the dynamic creation of my tree component as you mentioned, i.e. adding all the components to their parents before calling getClientId().But it seems that there is something more to do, looking at the generated code:
input id=tablaEdicionPuntuaciones0_0:_id30_0:_input 
name=tablaEdicionPuntuaciones0_0:_id30_0:_input type=text 
value=x+2 class=txt /
nbsp;a href='#'img src=
/DeltaR/images/check.gif alt=Validar height=
11 width=12 onclick=PuntuacionesAjax.validarFormula
(respuestaValidacion, getElmById('tablaEdicionPuntuaciones0:_id30:_input').value); return true /Can you see that the input ID is 
tablaEdicionPuntuaciones0_0:_id30_0:_input
, but the ID obtained from getClientId in the onclick method is tablaEdicionPuntuaciones0:_id30:_input
, where there is a _0 missing? Any ideas?I assert that the call to getClientId within my code is the last call, but as I use an HtmlDataTable, maybe there is another part of the ID I'm missing...
2006/1/19, Simon Kitching [EMAIL PROTECTED]:
I believe Volker's answer is exactly what you're looking for. UnlessI've misunderstood your question, method getClientId is what you want;you just need to make sure the component is attached to the view treebefore calling that method.
ie:UIOutput texto4 = createComponent(..);texto4.setId(texto4);// parent is expected to already be attached to the view tree.parent.getChildren().add(texto4);// do this only after adding to view tree. You'll then get the
// full final id of the component, eg form1:subview1:table3:texto4String texto4ClientId = texto4.getClientId(facesContext);// use texto4ClientId in _javascript_ emitted for some other component
If you need to find the texto4 client from some other renderer, youcan search for it:UIOutput text05 = createComponent(..);// find a component with the specified name within the same
// naming container as the component the find is invoked onUIOutput targetComponent = parent.findComponent(texto4);String targetClientId = targetComponent.getClientId();// use targetClientId in _javascript_ emitted for texto5 component
Note also that component ids starting with underscores are reserved forthe use of the JSF framework; any id you assign explicitly should *not*start with an underscore.Regards,Simon
On Thu, 2006-01-19 at 16:49 +0100, Enrique Medina wrote: See what is generated at runtime: input id=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input name=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input type=
 text value=12 > class=txt / And obviously, a component with _input ID does not exist, because as
 being contained, the ID generated for the input component is different... 2006/1/19, Volker Weber [EMAIL PROTECTED]
: Hi, you can get the rendered 'htmlId' of a component by component.getCientId(facesContext); so you can do : UIOutput texto5 = (HtmlOutputText)
 FacesUtils.getApplication().createComponent( HtmlOutputText.COMPONENT_TYPE); texto5.getAttributes().put(onclick, validate(' + 
texto4.getClientId(facesContext) + ')); Regards, Volker Enrique Medina wrote:  Also I forgot to say, that if I wanted to use the onclick
 method on the  same UIInput component, I could define it easily by:  texto4.getAttributes().put(onclick, validate( 
this.value));   As you can see, I know that 'this' refers to my component. But what  happens if I need to refer to texto4 component value from
 another  component. Imagine:   UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication()  .createComponent(
HtmlOutputText.COMPONENT_TYPE);   texto5.getAttributes().put(onclick, validate(XX));   where XX is a _javascript_ reference to the value of
 texto4.2006/1/19, Enrique Medina [EMAIL PROTECTED]  mailto: 
[EMAIL PROTECTED]:   Let me give a more detailed explanation of what I am trying to achieve.. 
  In my application I need to work with data in a spreadsheet form, so  I decided to use a PanelTabbed component, where each tab would  contain a HtmlDataTable. All these would simulate an
 Excel page,  where I can change the actual tab, make some modifications to the  elements in the table, go to another tab, modify, etc, so at the end
  I would press the save button, and all the changes would be  persisted to the DB.   The big problem I had with defining this page was the
 fact that all  the data that was used to populate the tables in each tab was not  known at compile time, as it depended on the values entered by the
  user during the normal use of the application.   So I had to create all the components dynamically through Java code.  To accomplish this objective, I created a JSP file with
 simply a  PanelTabbed tag that I binded to a property in my backing bean, so  whenever JSF called my setBindedTabbedPane method, I could create
  all the tabs, tables, labels, inputs, etc, in code.   Once done, everything was perfect, in the sense that my application  was implemented to dynamically create all the components
 needed to  simulate an Excel worksheet; i.e. dynamic 

Re: Dynamically refer to a component from another component

2006-01-20 Thread Simon Kitching
On Fri, 2006-01-20 at 11:22 +0100, Enrique Medina wrote:
 I have been implementing the dynamic creation of my tree component as
 you mentioned, i.e. adding all the components to their parents before
 calling getClientId().
 
 But it seems that there is something more to do, looking at the
 generated code: 
 
 input id=tablaEdicionPuntuaciones0_0:_id30_0:_input 

The extra _0 is because this input component is in the 0th row of a
table. A table is also a naming container.

In order to get the id for a component in a particular row of a table,
call
   tableComponent.setRowIndex(index);
   someChildComponentOfTable.getClientId(facesContext);

Normally the above is not necessary, as it's done implicitly by the
framework; the renderer for some component in a table is called once for
each row of the table, and the component's clientId is set at that time.
That's the normal JSF way of rendering: let the framework make calls
into the renderer with everything configured correctly. If you're
somehow driving rendering while bypassing the normal flow you'll need to
ensure the rowIndex is set correctly.

If you're not getting the _0 row bit, then clearly your rendering code
is not being called in the normal rendering flow.

Regards,

Simon




Re: Dynamically refer to a component from another component

2006-01-20 Thread Volker Weber
Hi Enrique,

the '_0' is added by the datatable while rendering row 1 (index 0).
This is needed to generate uniqe ids over multiple rows.

Looks like you have nested datatables?

To get the '_0' you can call setRowIndex(0) on the datatable component,
but if your table contains more rows the ids are incrementing each row
and you can't, at component creation time, not set different onclick
values for the rows.

if your data has only one row you can use setRowIndex() (but datatable
with one row ?),
otherwise you can try to get the correct index in your javascript code,
by parsing 'this.id' (you need of cause the this refferece in your
function call) and inserting the extracted id(s) at the corresponding
position(s) in the id of the needed element.

Regards,
  Volker

Enrique Medina wrote:
 I have been implementing the dynamic creation of my tree component as
 you mentioned, i.e. adding all the components to their parents before
 calling getClientId().
 
 But it seems that there is something more to do, looking at the
 generated code:
 
 input id=tablaEdicionPuntuaciones0_0:_id30_0:_input 
 
 name=tablaEdicionPuntuaciones0_0:_id30_0:_input 
 type=text 
 value=x+2 class=txt /
 
 nbsp;
 a href='#'
 img src=
 /DeltaR/images/check.gif alt=Validar 
 height=
 11 width=12 
 onclick=PuntuacionesAjax.validarFormula
 (respuestaValidacion, 
 getElmById('tablaEdicionPuntuaciones0:_id30:_input').value); return true /
 
 
 Can you see that the input ID is
 
 tablaEdicionPuntuaciones0_0:_id30_0:_input
 
 , but the ID obtained from getClientId in the onclick method is
 
 tablaEdicionPuntuaciones0:_id30:_input
 
 , where there is a _0 missing? Any ideas?
 
 I assert that the call to getClientId within my code is the last call,
 but as I use an HtmlDataTable, maybe there is another part of the ID I'm
 missing...
 
 2006/1/19, Simon Kitching [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]:
 
 I believe Volker's answer is exactly what you're looking for. Unless
 I've misunderstood your question, method getClientId is what you want;
 you just need to make sure the component is attached to the view tree
 before calling that method.
 
 ie:
 
   UIOutput texto4 = createComponent(..);
   texto4.setId(texto4);
 
   // parent is expected to already be attached to the view tree.
   parent.getChildren().add(texto4);
 
   // do this only after adding to view tree. You'll then get the
   // full final id of the component, eg form1:subview1:table3:texto4
   String texto4ClientId = texto4.getClientId(facesContext);
 
   // use texto4ClientId in javascript emitted for some other component
 
 If you need to find the texto4 client from some other renderer, you
 can search for it:
   
   UIOutput text05 = createComponent(..);
 
   // find a component with the specified name within the same
   // naming container as the component the find is invoked on
   UIOutput targetComponent = parent.findComponent(texto4);
 
   String targetClientId = targetComponent.getClientId();
   // use targetClientId in javascript emitted for texto5 component
 
 
 Note also that component ids starting with underscores are reserved for
 the use of the JSF framework; any id you assign explicitly should *not*
 start with an underscore.
 
 Regards,
 
 Simon
 
 On Thu, 2006-01-19 at 16:49 +0100, Enrique Medina wrote:
  See what is generated at runtime:
 
  input
 id=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input
 
 name=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input
 type=
  text value=12 onclick=myAlert(_input.value)
  class=txt /
 
  And obviously, a component with _input ID does not exist,
 because as
  being contained, the ID generated for the input component is
  different...
 
  2006/1/19, Volker Weber [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] :
  Hi,
 
  you can get the rendered 'htmlId' of a component by
component.getCientId(facesContext);
 
  so you can do :
 
UIOutput texto5 = (HtmlOutputText)
  FacesUtils.getApplication()
   .createComponent( HtmlOutputText.COMPONENT_TYPE);
 
texto5.getAttributes().put(onclick,
validate(' + texto4.getClientId(facesContext) + '));
 
  Regards,
Volker
 
  Enrique Medina wrote:
   Also I forgot to say, that if I wanted to use the onclick
  method on the
   same UIInput component, I could define it easily by:
  
texto4.getAttributes().put(onclick,
  validate( this.value));
  
   As you can see, I know that 'this' refers to my component.
  But what
   happens if I need to refer to texto4 component value 

Re: Dynamically refer to a component from another component

2006-01-20 Thread Enrique Medina
Well, the problem is that I'm creating the table in code using a DataModel for columns and a DataModel for rows, so at that time the row index is not known, is it?And as I assign the client ID at code, how can I know the row?
2006/1/20, Simon Kitching [EMAIL PROTECTED]:
On Fri, 2006-01-20 at 11:22 +0100, Enrique Medina wrote: I have been implementing the dynamic creation of my tree component as you mentioned, i.e. adding all the components to their parents before calling getClientId().
 But it seems that there is something more to do, looking at the generated code: input id=tablaEdicionPuntuaciones0_0:_id30_0:_inputThe extra _0 is because this input component is in the 0th row of a
table. A table is also a naming container.In order to get the id for a component in a particular row of a table,call tableComponent.setRowIndex(index); someChildComponentOfTable.getClientId(facesContext);
Normally the above is not necessary, as it's done implicitly by theframework; the renderer for some component in a table is called once foreach row of the table, and the component's clientId is set at that time.
That's the normal JSF way of rendering: let the framework make callsinto the renderer with everything configured correctly. If you'resomehow driving rendering while bypassing the normal flow you'll need to
ensure the rowIndex is set correctly.If you're not getting the _0 row bit, then clearly your rendering codeis not being called in the normal rendering flow.Regards,Simon



Re: Dynamically refer to a component from another component

2006-01-20 Thread Volker Weber
BTW: if i remember correct the generated row index is changed to ':0' in
svn.

Volker Weber wrote:
 Hi Enrique,
 
 the '_0' is added by the datatable while rendering row 1 (index 0).
 This is needed to generate uniqe ids over multiple rows.
 
 Looks like you have nested datatables?
 
 To get the '_0' you can call setRowIndex(0) on the datatable component,
 but if your table contains more rows the ids are incrementing each row
 and you can't, at component creation time, not set different onclick
 values for the rows.
 
 if your data has only one row you can use setRowIndex() (but datatable
 with one row ?),
 otherwise you can try to get the correct index in your javascript code,
 by parsing 'this.id' (you need of cause the this refferece in your
 function call) and inserting the extracted id(s) at the corresponding
 position(s) in the id of the needed element.
 
 Regards,
   Volker
 
 Enrique Medina wrote:
 
I have been implementing the dynamic creation of my tree component as
you mentioned, i.e. adding all the components to their parents before
calling getClientId().

But it seems that there is something more to do, looking at the
generated code:

input id=tablaEdicionPuntuaciones0_0:_id30_0:_input 

name=tablaEdicionPuntuaciones0_0:_id30_0:_input 
type=text 
value=x+2 class=txt /

nbsp;
a href='#'
img src=
/DeltaR/images/check.gif alt=Validar 
height=
11 width=12 
onclick=PuntuacionesAjax.validarFormula
(respuestaValidacion, 
getElmById('tablaEdicionPuntuaciones0:_id30:_input').value); return true /


Can you see that the input ID is

tablaEdicionPuntuaciones0_0:_id30_0:_input

, but the ID obtained from getClientId in the onclick method is

tablaEdicionPuntuaciones0:_id30:_input

, where there is a _0 missing? Any ideas?

I assert that the call to getClientId within my code is the last call,
but as I use an HtmlDataTable, maybe there is another part of the ID I'm
missing...

2006/1/19, Simon Kitching [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]:

I believe Volker's answer is exactly what you're looking for. Unless
I've misunderstood your question, method getClientId is what you want;
you just need to make sure the component is attached to the view tree
before calling that method.

ie:

  UIOutput texto4 = createComponent(..);
  texto4.setId(texto4);

  // parent is expected to already be attached to the view tree.
  parent.getChildren().add(texto4);

  // do this only after adding to view tree. You'll then get the
  // full final id of the component, eg form1:subview1:table3:texto4
  String texto4ClientId = texto4.getClientId(facesContext);

  // use texto4ClientId in javascript emitted for some other component

If you need to find the texto4 client from some other renderer, you
can search for it:
  
  UIOutput text05 = createComponent(..);

  // find a component with the specified name within the same
  // naming container as the component the find is invoked on
  UIOutput targetComponent = parent.findComponent(texto4);

  String targetClientId = targetComponent.getClientId();
  // use targetClientId in javascript emitted for texto5 component


Note also that component ids starting with underscores are reserved for
the use of the JSF framework; any id you assign explicitly should *not*
start with an underscore.

Regards,

Simon

On Thu, 2006-01-19 at 16:49 +0100, Enrique Medina wrote:
 See what is generated at runtime:

 input
id=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input

name=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input
type=
 text value=12 onclick=myAlert(_input.value)
 class=txt /

 And obviously, a component with _input ID does not exist,
because as
 being contained, the ID generated for the input component is
 different...

 2006/1/19, Volker Weber [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] :
 Hi,

 you can get the rendered 'htmlId' of a component by
   component.getCientId(facesContext);

 so you can do :

   UIOutput texto5 = (HtmlOutputText)
 FacesUtils.getApplication()
  .createComponent( HtmlOutputText.COMPONENT_TYPE);

   texto5.getAttributes().put(onclick,
   validate(' + texto4.getClientId(facesContext) + '));

 Regards,
   Volker

 Enrique Medina wrote:
  Also I forgot to say, that if I wanted to use the onclick
 method on the
  same UIInput component, I could define it easily by:
 
   texto4.getAttributes().put(onclick,
 validate( this.value));
 
  As you can see, I know that 'this' refers to my component.
 But what
  happens if I need to refer to texto4 component value from
  

Re: Dynamically refer to a component from another component

2006-01-20 Thread Simon Kitching
If your component is a column in a table, and the table has 5 rows then
there will be 5 HTML tags generated for that component. Each needs a
distinct id according to the rules for HTML.

If you're planning on manipulating those objects in javascript, your
javascript needs to handle the fact that there are 5 of those HTML
elements around. That's not JSF-specific, that's the nature of the
problem.

On Fri, 2006-01-20 at 11:49 +0100, Enrique Medina wrote:
 Well, the problem is that I'm creating the table in code using a
 DataModel for columns and a DataModel for rows, so at that time the
 row  index is not known, is it?
 
 And as I assign the client ID at code, how can I know the row? 
 
 2006/1/20, Simon Kitching [EMAIL PROTECTED]:
 On Fri, 2006-01-20 at 11:22 +0100, Enrique Medina wrote:
  I have been implementing the dynamic creation of my tree
 component as
  you mentioned, i.e. adding all the components to their
 parents before
  calling getClientId(). 
 
  But it seems that there is something more to do, looking at
 the
  generated code:
 
  input id=tablaEdicionPuntuaciones0_0:_id30_0:_input
 
 The extra _0 is because this input component is in the 0th row
 of a 
 table. A table is also a naming container.
 
 In order to get the id for a component in a particular row of
 a table,
 call
tableComponent.setRowIndex(index);
someChildComponentOfTable.getClientId(facesContext); 
 
 Normally the above is not necessary, as it's done implicitly
 by the
 framework; the renderer for some component in a table is
 called once for
 each row of the table, and the component's clientId is set at
 that time. 
 That's the normal JSF way of rendering: let the framework make
 calls
 into the renderer with everything configured correctly. If
 you're
 somehow driving rendering while bypassing the normal flow
 you'll need to
 ensure the rowIndex is set correctly.
 
 If you're not getting the _0 row bit, then clearly your
 rendering code
 is not being called in the normal rendering flow.
 
 Regards,
 
 Simon 
 
 
 



Re: Dynamically refer to a component from another component

2006-01-20 Thread Enrique Medina
Simon,The problem is that I don't know how many rows I will have, as it depens on the data the user enters in the normal use of the application.And I need to manipulate the value of the input object using _javascript_, but the value itself must be indicated in code the way you told me in your previous email. See what I mean?
2006/1/20, Simon Kitching [EMAIL PROTECTED]:
If your component is a column in a table, and the table has 5 rows thenthere will be 5 HTML tags generated for that component. Each needs adistinct id according to the rules for HTML.If you're planning on manipulating those objects in _javascript_, your
_javascript_ needs to handle the fact that there are 5 of those HTMLelements around. That's not JSF-specific, that's the nature of theproblem.On Fri, 2006-01-20 at 11:49 +0100, Enrique Medina wrote: Well, the problem is that I'm creating the table in code using a
 DataModel for columns and a DataModel for rows, so at that time the rowindex is not known, is it? And as I assign the client ID at code, how can I know the row? 2006/1/20, Simon Kitching 
[EMAIL PROTECTED]: On Fri, 2006-01-20 at 11:22 +0100, Enrique Medina wrote:  I have been implementing the dynamic creation of my tree
 component as  you mentioned, i.e. adding all the components to their parents before  calling getClientId().   But it seems that there is something more to do, looking at
 the  generated code:   input id=tablaEdicionPuntuaciones0_0:_id30_0:_input The extra _0 is because this input component is in the 0th row
 of a table. A table is also a naming container. In order to get the id for a component in a particular row of a table, call
tableComponent.setRowIndex(index);someChildComponentOfTable.getClientId(facesContext); Normally the above is not necessary, as it's done implicitly by the framework; the renderer for some component in a table is
 called once for each row of the table, and the component's clientId is set at that time. That's the normal JSF way of rendering: let the framework make calls
 into the renderer with everything configured correctly. If you're somehow driving rendering while bypassing the normal flow you'll need to ensure the rowIndex is set correctly.
 If you're not getting the _0 row bit, then clearly your rendering code is not being called in the normal rendering flow. Regards,
 Simon


Re: Dynamically refer to a component from another component

2006-01-20 Thread Simon Kitching
On Fri, 2006-01-20 at 12:04 +0100, Enrique Medina wrote:
 Simon,
 
 The problem is that I don't know how many rows I will have, as it
 depens on the data the user enters in the normal use of the
 application.
 
 And I need to manipulate the value of the input object using
 Javascript, but the value itself must be indicated in code the way you
 told me in your previous email. See what I mean? 

So you have some component (eg a button) that when clicked needs to
perform some operation on each row of column N in a table?

Then how about having each of your (custom) components in a table emit
script like:
  script
register_name_field('client-id-goes-here');
  /script

You provide a javascript function register_name_field that adds the
parameter to a list variable in the page. Result: as the html page is
processed, each such component adds its id to a list that can be
accessed later.

Regards,

Simon



RE: Dynamically refer to a component from another component

2006-01-20 Thread Jesse Alexander \(KBSA 21\)



You could help _javascript_ by generating a hidden field with 
a given id and the number of rows as value...

hth
Alexander


From: Enrique Medina 
[mailto:[EMAIL PROTECTED] Sent: Friday, January 20, 2006 12:05 
PMTo: [EMAIL PROTECTED]; MyFaces DiscussionSubject: Re: 
Dynamically refer to a component from another component
Simon,The problem is that I don't know how many rows I will 
have, as it depens on the data the user enters in the normal use of the 
application.And I need to manipulate the value of the input object using 
_javascript_, but the value itself must be indicated in code the way you told me 
in your previous email. See what I mean? 
2006/1/20, Simon Kitching [EMAIL PROTECTED]:
If 
  your component is a column in a table, and the table has 5 rows thenthere 
  will be 5 HTML tags generated for that component. Each needs adistinct id 
  according to the rules for HTML.If you're planning on manipulating 
  those objects in _javascript_, your _javascript_ needs to handle the fact that 
  there are 5 of those HTMLelements around. That's not JSF-specific, that's 
  the nature of theproblem.On Fri, 2006-01-20 at 11:49 +0100, 
  Enrique Medina wrote: Well, the problem is that I'm creating the table 
  in code using a  DataModel for columns and a DataModel for rows, so at 
  that time the rowindex is not known, is 
  it? And as I assign the client ID at code, how can I know the 
  row? 2006/1/20, Simon Kitching  [EMAIL PROTECTED]: 
  On Fri, 2006-01-20 at 11:22 +0100, Enrique Medina 
  wrote:  I have 
  been implementing the dynamic creation of my 
  tree component 
  as  you mentioned, 
  i.e. adding all the components to 
  their parents 
  before  calling 
  getClientId(). 
But it seems 
  that there is something more to do, looking at 
   
  the  generated 
  code: 
input 
  id="tablaEdicionPuntuaciones0_0:_id30_0:_input" 
  The extra _0 is because this input component is in the 0th row 
   of 
  a table. A table is 
  also a naming 
  container. In 
  order to get the id for a component in a particular row 
  of a 
  table, 
  call 
  tableComponent.setRowIndex(index);someChildComponentOfTable.getClientId(facesContext); 
  Normally the above is not necessary, as it's done 
  implicitly by 
  the framework; the 
  renderer for some component in a table is 
   called once 
  for each row of the 
  table, and the component's clientId is set 
  at that 
  time. That's the 
  normal JSF way of rendering: let the framework 
  make calls 
   into the renderer 
  with everything configured correctly. 
  If 
  you're somehow driving 
  rendering while bypassing the normal 
  flow you'll need 
  to ensure the rowIndex 
  is set correctly. 
   If you're not 
  getting the "_0" row bit, then clearly 
  your rendering 
  code is not being 
  called in the "normal rendering 
  flow". 
  Regards,  
  Simon


Re: Dynamically refer to a component from another component

2006-01-20 Thread Enrique Medina
I see. But it's not that exactly. Suppose I have a button associated to each INPUT object, that when clicked must perform a particular action for the value of the INPUT associated, not another...
2006/1/20, Simon Kitching [EMAIL PROTECTED]:
On Fri, 2006-01-20 at 12:04 +0100, Enrique Medina wrote: Simon, The problem is that I don't know how many rows I will have, as it depens on the data the user enters in the normal use of the
 application. And I need to manipulate the value of the input object using _javascript_, but the value itself must be indicated in code the way you told me in your previous email. See what I mean?
So you have some component (eg a button) that when clicked needs toperform some operation on each row of column N in a table?Then how about having each of your (custom) components in a table emitscript like:
scriptregister_name_field('client-id-goes-here');/scriptYou provide a _javascript_ function register_name_field that adds theparameter to a list variable in the page. Result: as the html page is
processed, each such component adds its id to a list that can beaccessed later.Regards,Simon


Re: Dynamically refer to a component from another component

2006-01-20 Thread Enrique Medina
For those who might be interested...FInally I solved my problem. When the dataTable is being rendered, then it uses both the row number and the col number to generate the IDs, so I made use of the rowIndexVar and var properties of DataTable and UIColumns respectively to be able to access this information at runtime through EL. Then I created a simple _javascript_ function that replaced the ID I had at my code, with the extra information of rows and cols.
Works like a charmThanks very much again for those who have given me help and tips ;-)2006/1/20, Enrique Medina [EMAIL PROTECTED]
:I see. But it's not that exactly. Suppose I have a button associated to each INPUT object, that when clicked must perform a particular action for the value of the INPUT associated, not another...

2006/1/20, Simon Kitching [EMAIL PROTECTED]:

On Fri, 2006-01-20 at 12:04 +0100, Enrique Medina wrote: Simon, The problem is that I don't know how many rows I will have, as it depens on the data the user enters in the normal use of the
 application. And I need to manipulate the value of the input object using _javascript_, but the value itself must be indicated in code the way you told me in your previous email. See what I mean?
So you have some component (eg a button) that when clicked needs toperform some operation on each row of column N in a table?Then how about having each of your (custom) components in a table emitscript like:
scriptregister_name_field('client-id-goes-here');/scriptYou provide a _javascript_ function register_name_field that adds theparameter to a list variable in the page. Result: as the html page is
processed, each such component adds its id to a list that can beaccessed later.Regards,Simon



Re: Dynamically refer to a component from another component

2006-01-19 Thread Simon Kitching
http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother

On Thu, 2006-01-19 at 12:57 +0100, Enrique Medina wrote:
 Anyone can give me some hints on how to refer from one component to
 another using EL, or maybe when creating the components dynamically
 through code?




Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
Hi Simon,I mean accesing one component to another from inside the same bean2006/1/19, Simon Kitching [EMAIL PROTECTED]:
http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
On Thu, 2006-01-19 at 12:57 +0100, Enrique Medina wrote: Anyone can give me some hints on how to refer from one component to another using EL, or maybe when creating the components dynamically
 through code?


Re: Dynamically refer to a component from another component

2006-01-19 Thread Mario Ivankovits
Hi Enrique!

But this is what Simon tries to show you.
Its possible to inject the other bean instance or to look it up through
the context.

Ciao,
Mario
 Hi Simon,

 I mean accesing one component to another from inside the same bean

 2006/1/19, Simon Kitching [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]:

 http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
 http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother

 On Thu, 2006-01-19 at 12:57 +0100, Enrique Medina wrote:
  Anyone can give me some hints on how to refer from one component to
  another using EL, or maybe when creating the components dynamically
  through code?





-- 
Mario



Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
But I don't want to inject another bean. When I talk about components I mean view components in the model component; e.g. refer to an HtmlInputText from another HtmlOutputText.The problem I have is that I need to refer to the value of one component from another one in code, and both of them are dynamically created in the same backing bean.
2006/1/19, Mario Ivankovits [EMAIL PROTECTED]:
Hi Enrique!But this is what Simon tries to show you.Its possible to inject the other bean instance or to look it up throughthe context.Ciao,Mario Hi Simon, I mean accesing one component to another from inside the same bean
 2006/1/19, Simon Kitching [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]: 
http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother 
http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother On Thu, 2006-01-19 at 12:57 +0100, Enrique Medina wrote:  Anyone can give me some hints on how to refer from one component to
  another using EL, or maybe when creating the components dynamically  through code?--Mario


RE: Dynamically refer to a component from another component

2006-01-19 Thread Jesse Alexander \(KBSA 21\)



Do you know the parent bean?
Do you know the id of the 
othercomponent?

findComponent(java.lang.Stringexpr) 
Search for and 
return the UIComponent with an id that matches the specified search _expression_ (if any), 
according to the algorithm described below. 

This method exists in UIComponent

Could this be a ticket to ride?
Alexander


From: Enrique Medina 
[mailto:[EMAIL PROTECTED] Sent: Thursday, January 19, 2006 2:48 
PMTo: MyFaces DiscussionSubject: Re: Dynamically refer to 
a component from another component
But I don't want to inject another bean. When I talk about components 
I mean view components in the model component; e.g. refer to an HtmlInputText 
from another HtmlOutputText.The problem I have is that I need to refer 
to the value of one component from another one in code, and both of them are 
dynamically created in the same backing bean. 
2006/1/19, Mario Ivankovits [EMAIL PROTECTED]:
Hi 
  Enrique!But this is what Simon tries to show you.Its possible to 
  inject the other bean instance or to look it up throughthe 
  context.Ciao,Mario Hi Simon, I mean 
  accesing one component to another from inside the same bean  
  2006/1/19, Simon Kitching [EMAIL PROTECTED] 
  mailto:[EMAIL PROTECTED]: 
  http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother 
   
  http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother 
  On Thu, 2006-01-19 at 12:57 +0100, Enrique Medina 
  wrote:  Anyone can give me some hints on 
  how to refer from one component to   
  another using EL, or maybe when creating the components 
  dynamically  through 
  code?--Mario


Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
Hi Jesse,The problem is I don't know the HTML ID until the page is rendered, and that ID is the one I want to refer in code, as it will be the input to a _javascript_ method.2006/1/19, Jesse Alexander (KBSA 21) 
[EMAIL PROTECTED]:





Do you know the parent bean?
Do you know the id of the 
othercomponent?


findComponent(java.lang.Stringexpr) 
Search for and 
return the UIComponent
 with an id that matches the specified search _expression_ (if any), 
according to the algorithm described below. 

This method exists in UIComponent

Could this be a ticket to ride?
Alexander


From: Enrique Medina 
[mailto:[EMAIL PROTECTED]] Sent: Thursday, January 19, 2006 2:48 
PMTo: MyFaces DiscussionSubject: Re: Dynamically refer to 
a component from another component
But I don't want to inject another bean. When I talk about components 
I mean view components in the model component; e.g. refer to an HtmlInputText 
from another HtmlOutputText.The problem I have is that I need to refer 
to the value of one component from another one in code, and both of them are 
dynamically created in the same backing bean. 
2006/1/19, Mario Ivankovits [EMAIL PROTECTED]:
Hi 
  Enrique!But this is what Simon tries to show you.Its possible to 
  inject the other bean instance or to look it up throughthe 
  context.Ciao,Mario Hi Simon, I mean 
  accesing one component to another from inside the same bean  
  2006/1/19, Simon Kitching [EMAIL PROTECTED] 
  mailto:[EMAIL PROTECTED]: 
  http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
 
   
  http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother 
  On Thu, 2006-01-19 at 12:57 +0100, Enrique Medina 
  wrote:  Anyone can give me some hints on 
  how to refer from one component to   
  another using EL, or maybe when creating the components 
  dynamically  through 
  code?--Mario




Re: Dynamically refer to a component from another component

2006-01-19 Thread Volker Weber
Hi,

Enrique Medina wrote:
 But I don't want to inject another bean. When I talk about components I
 mean view components in the model component; e.g. refer to an
 HtmlInputText from another HtmlOutputText.
 
 The problem I have is that I need to refer to the value of one component
 from another one in code, and both of them are dynamically created in
 the same backing bean.
 

If you create the components you can store references to them in your bean.

Ohterwise you need to walk through the component tree, or try to fetch
them via findComponent(id) method.

Regards,
  Volker

-- 
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.


Re: Dynamically refer to a component from another component

2006-01-19 Thread Mario Ivankovits
Enrique Medina schrieb:
 The problem is I don't know the HTML ID until the page is rendered,
 and that ID is the one I want to refer in code, as it will be the
 input to a Javascript method.
and what if you set a binding in your created components so they will
automatically register to your component.

it should be possible to set a binding like
'#{componentCollector.components['internal-id']}' where components
points to a map.

Ciao,
Mario



Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
Let me give a more detailed explanation of what I am trying to achieve..In my application I need to work with data in a spreadsheet form, so I decided to use a PanelTabbed component, where each tab would contain a HtmlDataTable. All these would simulate an Excel page, where I can change the actual tab, make some modifications to the elements in the table, go to another tab, modify, etc, so at the end I would press the save button, and all the changes would be persisted to the DB.
The big problem I had with defining this page was the fact that all the data that was used to populate the tables in each tab was not known at compile time, as it depended on the values entered by the user during the normal use of the application.
So I had to create all the components dynamically through Java code. To accomplish this objective, I created a JSP file with simply a PanelTabbed tag that I binded to a property in my backing bean, so whenever JSF called my setBindedTabbedPane method, I could create all the tabs, tables, labels, inputs, etc, in code.
Once done, everything was perfect, in the sense that my application was implemented to dynamically create all the components needed to simulate an Excel worksheet; i.e. dynamic number of columns and rows, dynamic number of tabs, etc.
On the other hand, I have also added DWR to my application in order to use Ajax for particular purposes, like showing child data in a datatable, or simply validate some specific fields without having to make a JSF request. So I decided to add a DWR Ajax validate process to my recently created Excel worksheet.
But the problem comes because when using DWR Ajax, I need to define a callback function in _javascript_ where I have to pass as a parameter the value that I want to be validated. As you already know, I am generating all the components dynamically in code, within a loop that reuses temporal variable names for the sake of performance and clearness. This means that I use the 
FacesContext.getApplication().createComponent() to create every component, but reusing the same variable in the loop, as I don't know how many components will I have to create (i.e. how many inputs or datatables or tabs).
To better clarify, imagine that I want to add a _javascript_ call in the onclick method of an input text box. When creating the component dynamically, I could do:   UIInput texto4 = (HtmlInputText) 
FacesUtils.getApplication() .createComponent(HtmlInputText.COMPONENT_TYPE);   texto4.getAttributes().put(styleClass, txt);   texto4 .setValueBinding(
   rendered,   FacesUtils .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['   + codigoGrupo
   + '].puntuacionColumna != null}));   texto4 .setValueBinding(   value,   FacesUtils
 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['   + codigoGrupo   + '].puntuacionColumna}));
Please notice that this piece of code will be executed for each input text box that is needed. If I set the Id with:   texto4.setId(_input);Then this ID will be used as the last part of the HTML generated ID when rendering the page, so there is no way to know it when writing this code in the backing bean.
So in the end, my question was about how could I know that ID at runtime. I mean, I can use EL to bind values with my objects' properties, but could I also do something similar with component attributes?
2006/1/19, Volker Weber [EMAIL PROTECTED]:
Hi,Enrique Medina wrote: But I don't want to inject another bean. When I talk about components I mean view components in the model component; e.g. refer to an HtmlInputText from another HtmlOutputText.
 The problem I have is that I need to refer to the value of one component from another one in code, and both of them are dynamically created in the same backing bean.If you create the components you can store references to them in your bean.
Ohterwise you need to walk through the component tree, or try to fetchthem via findComponent(id) method.Regards,Volker--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 byconcatenating my forename to my senders domain.


Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
Also I forgot to say, that if I wanted to use the onclick method on the same UIInput component, I could define it easily by: texto4.getAttributes().put(onclick, validate(this.value));
As you can see, I know that 'this' refers to my component. But what happens if I need to refer to texto4 component value from another component. Imagine:   UIOutput texto5 = (HtmlOutputText) 
FacesUtils.getApplication() .createComponent(HtmlOutputText.COMPONENT_TYPE); texto5.getAttributes().put(onclick, validate(XX));where XX is a _javascript_ reference to the value of texto4.
2006/1/19, Enrique Medina [EMAIL PROTECTED]:
Let me give a more detailed explanation of what I am trying to achieve..In my application I need to work with data in a spreadsheet form, so I decided to use a PanelTabbed component, where each tab would contain a HtmlDataTable. All these would simulate an Excel page, where I can change the actual tab, make some modifications to the elements in the table, go to another tab, modify, etc, so at the end I would press the save button, and all the changes would be persisted to the DB.
The big problem I had with defining this page was the fact that all the data that was used to populate the tables in each tab was not known at compile time, as it depended on the values entered by the user during the normal use of the application.
So I had to create all the components dynamically through Java code. To accomplish this objective, I created a JSP file with simply a PanelTabbed tag that I binded to a property in my backing bean, so whenever JSF called my setBindedTabbedPane method, I could create all the tabs, tables, labels, inputs, etc, in code.
Once done, everything was perfect, in the sense that my application was implemented to dynamically create all the components needed to simulate an Excel worksheet; i.e. dynamic number of columns and rows, dynamic number of tabs, etc.
On the other hand, I have also added DWR to my application in order to use Ajax for particular purposes, like showing child data in a datatable, or simply validate some specific fields without having to make a JSF request. So I decided to add a DWR Ajax validate process to my recently created Excel worksheet.
But the problem comes because when using DWR Ajax, I need to define a callback function in _javascript_ where I have to pass as a parameter the value that I want to be validated. As you already know, I am generating all the components dynamically in code, within a loop that reuses temporal variable names for the sake of performance and clearness. This means that I use the 
FacesContext.getApplication().createComponent() to create every component, but reusing the same variable in the loop, as I don't know how many components will I have to create (i.e. how many inputs or datatables or tabs).
To better clarify, imagine that I want to add a _javascript_ call in the onclick method of an input text box. When creating the component dynamically, I could do:   UIInput texto4 = (HtmlInputText) 
FacesUtils.getApplication() .createComponent(HtmlInputText.COMPONENT_TYPE);   texto4.getAttributes().put(styleClass, txt);   texto4 .setValueBinding(
   rendered,   FacesUtils .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['   + codigoGrupo
   + '].puntuacionColumna != null}));   texto4 .setValueBinding(   value,   FacesUtils
 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['   + codigoGrupo   + '].puntuacionColumna}));
Please notice that this piece of code will be executed for each input text box that is needed. If I set the Id with:   texto4.setId(_input);Then this ID will be used as the last part of the HTML generated ID when rendering the page, so there is no way to know it when writing this code in the backing bean.
So in the end, my question was about how could I know that ID at runtime. I mean, I can use EL to bind values with my objects' properties, but could I also do something similar with component attributes?

2006/1/19, Volker Weber [EMAIL PROTECTED]:

Hi,Enrique Medina wrote: But I don't want to inject another bean. When I talk about components I mean view components in the model component; e.g. refer to an HtmlInputText from another HtmlOutputText.
 The problem I have is that I need to refer to the value of one component from another one in code, and both of them are dynamically created in the same backing bean.If you create the components you can store references to them in your bean.
Ohterwise you need to walk through the component tree, or try to fetchthem via findComponent(id) method.Regards,Volker--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 byconcatenating my forename to my senders domain.



Re: Dynamically refer to a component from another component

2006-01-19 Thread Volker Weber
Hi,

you can get the rendered 'htmlId' of a component by
  component.getCientId(facesContext);

so you can do :

  UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication()
 .createComponent(HtmlOutputText.COMPONENT_TYPE);

  texto5.getAttributes().put(onclick,
  validate(' + texto4.getClientId(facesContext) + '));

Regards,
  Volker

Enrique Medina wrote:
 Also I forgot to say, that if I wanted to use the onclick method on the
 same UIInput component, I could define it easily by:
 
  texto4.getAttributes().put(onclick, validate(this.value));
 
 As you can see, I know that 'this' refers to my component. But what
 happens if I need to refer to texto4 component value from another
 component. Imagine:
 
 UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication()
 .createComponent(HtmlOutputText.COMPONENT_TYPE);
 
 texto5.getAttributes().put(onclick, validate(XX));
 
 where XX is a Javascript reference to the value of texto4.
 
 
 2006/1/19, Enrique Medina [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]:
 
 Let me give a more detailed explanation of what I am trying to achieve..
 
 In my application I need to work with data in a spreadsheet form, so
 I decided to use a PanelTabbed component, where each tab would
 contain a HtmlDataTable. All these would simulate an Excel page,
 where I can change the actual tab, make some modifications to the
 elements in the table, go to another tab, modify, etc, so at the end
 I would press the save button, and all the changes would be
 persisted to the DB.
 
 The big problem I had with defining this page was the fact that all
 the data that was used to populate the tables in each tab was not
 known at compile time, as it depended on the values entered by the
 user during the normal use of the application.
 
 So I had to create all the components dynamically through Java code.
 To accomplish this objective, I created a JSP file with simply a
 PanelTabbed tag that I binded to a property in my backing bean, so
 whenever JSF called my setBindedTabbedPane method, I could create
 all the tabs, tables, labels, inputs, etc, in code.
 
 Once done, everything was perfect, in the sense that my application
 was implemented to dynamically create all the components needed to
 simulate an Excel worksheet; i.e. dynamic number of columns and
 rows, dynamic number of tabs, etc.
 
 On the other hand, I have also added DWR to my application in order
 to use Ajax for particular purposes, like showing child data in a
 datatable, or simply validate some specific fields without having to
 make a JSF request. So I decided to add a DWR Ajax validate process
 to my recently created Excel worksheet.
 
 But the problem comes because when using DWR Ajax, I need to define
 a callback function in Javascript where I have to pass as a
 parameter the value that I want to be validated. As you already
 know, I am generating all the components dynamically in code, within
 a loop that reuses temporal variable names for the sake of
 performance and clearness. This means that I use the
 FacesContext.getApplication().createComponent() to create every
 component, but reusing the same variable in the loop, as I don't
 know how many components will I have to create (i.e. how many inputs
 or datatables or tabs).
 
 To better clarify, imagine that I want to add a Javascript call in
 the onclick method of an input text box. When creating the component
 dynamically, I could do:
 
 UIInput texto4 = (HtmlInputText) FacesUtils.getApplication()
 .createComponent(HtmlInputText.COMPONENT_TYPE);
 
 texto4.getAttributes().put(styleClass, txt);
 texto4
 .setValueBinding(
 rendered,
 FacesUtils

 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['
 + codigoGrupo
 + '].puntuacionColumna
 != null}));
 texto4
 .setValueBinding(
 value,
 FacesUtils

 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['
 + codigoGrupo
 +
 '].puntuacionColumna}));
 
 Please notice that this piece of code will be executed for each
 input text box that is needed. If I set the Id with:
 
 texto4.setId(_input);
 
 Then this ID will be used as the last part of the HTML generated ID
 when rendering the page, so there is no way to know it 

Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
I tried that, but at the time of creating the component in code, texto4.getClientId(facesContext) returns exactly the same used before when texto4.setId(_input), so it doesn't help at all
2006/1/19, Volker Weber [EMAIL PROTECTED]:
Hi,you can get the rendered 'htmlId' of a component bycomponent.getCientId(facesContext);so you can do :UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication() .createComponent(
HtmlOutputText.COMPONENT_TYPE);texto5.getAttributes().put(onclick,validate(' + texto4.getClientId(facesContext) + '));Regards,VolkerEnrique Medina wrote:
 Also I forgot to say, that if I wanted to use the onclick method on the same UIInput component, I could define it easily by:texto4.getAttributes().put(onclick, validate(
this.value)); As you can see, I know that 'this' refers to my component. But what happens if I need to refer to texto4 component value from another component. Imagine:
 UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication() .createComponent(HtmlOutputText.COMPONENT_TYPE); texto5.getAttributes().put(onclick, validate(XX));
 where XX is a _javascript_ reference to the value of texto4. 2006/1/19, Enrique Medina [EMAIL PROTECTED] mailto:
[EMAIL PROTECTED]: Let me give a more detailed explanation of what I am trying to achieve.. In my application I need to work with data in a spreadsheet form, so
 I decided to use a PanelTabbed component, where each tab would contain a HtmlDataTable. All these would simulate an Excel page, where I can change the actual tab, make some modifications to the
 elements in the table, go to another tab, modify, etc, so at the end I would press the save button, and all the changes would be persisted to the DB. The big problem I had with defining this page was the fact that all
 the data that was used to populate the tables in each tab was not known at compile time, as it depended on the values entered by the user during the normal use of the application.
 So I had to create all the components dynamically through Java code. To accomplish this objective, I created a JSP file with simply a PanelTabbed tag that I binded to a property in my backing bean, so
 whenever JSF called my setBindedTabbedPane method, I could create all the tabs, tables, labels, inputs, etc, in code. Once done, everything was perfect, in the sense that my application
 was implemented to dynamically create all the components needed to simulate an Excel worksheet; i.e. dynamic number of columns and rows, dynamic number of tabs, etc. On the other hand, I have also added DWR to my application in order
 to use Ajax for particular purposes, like showing child data in a datatable, or simply validate some specific fields without having to make a JSF request. So I decided to add a DWR Ajax validate process
 to my recently created Excel worksheet. But the problem comes because when using DWR Ajax, I need to define a callback function in _javascript_ where I have to pass as a parameter the value that I want to be validated. As you already
 know, I am generating all the components dynamically in code, within a loop that reuses temporal variable names for the sake of performance and clearness. This means that I use the
 FacesContext.getApplication().createComponent() to create every component, but reusing the same variable in the loop, as I don't know how many components will I have to create (i.e. how many inputs
 or datatables or tabs). To better clarify, imagine that I want to add a _javascript_ call in the onclick method of an input text box. When creating the component dynamically, I could do:
 UIInput texto4 = (HtmlInputText) FacesUtils.getApplication() .createComponent(HtmlInputText.COMPONENT_TYPE); texto4.getAttributes
().put(styleClass, txt); texto4 .setValueBinding( rendered, FacesUtils
 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones[' + codigoGrupo + '].puntuacionColumna
 != null})); texto4 .setValueBinding( value, FacesUtils
 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones[' + codigoGrupo +
 '].puntuacionColumna})); Please notice that this piece of code will be executed for each input text box that is needed. If I set the Id with: 
texto4.setId(_input); Then this ID will be used as the last part of the HTML generated ID when rendering the page, so there is no way to know it when writing this code in the backing bean.
 So in the end, my question was about how could I know that ID at runtime. I mean, I can use EL to bind values with my objects' properties, but could I also do something similar with component
 attributes? 2006/1/19, Volker Weber [EMAIL PROTECTED] mailto:
[EMAIL PROTECTED]: Hi, Enrique Medina wrote: But I don't want to inject another bean. When I talk about components I
 mean view components in the model component; e.g. refer to an HtmlInputText from another HtmlOutputText. The problem I have is that I need to refer to the value of one component
 from another one in code, and both of them are dynamically created in the same backing 

Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
See what is generated at runtime:input id=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input 
name=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input type=
text value=12 onclick=myAlert(_input.value) 
class=txt /And obviously, a component with _input ID does not exist, because as being contained, the ID generated for the input component is different...
2006/1/19, Volker Weber [EMAIL PROTECTED]:
Hi,you can get the rendered 'htmlId' of a component bycomponent.getCientId(facesContext);so you can do :UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication() .createComponent(
HtmlOutputText.COMPONENT_TYPE);texto5.getAttributes().put(onclick,validate(' + texto4.getClientId(facesContext) + '));Regards,VolkerEnrique Medina wrote:
 Also I forgot to say, that if I wanted to use the onclick method on the same UIInput component, I could define it easily by:texto4.getAttributes().put(onclick, validate(
this.value)); As you can see, I know that 'this' refers to my component. But what happens if I need to refer to texto4 component value from another component. Imagine:
 UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication() .createComponent(HtmlOutputText.COMPONENT_TYPE); texto5.getAttributes().put(onclick, validate(XX));
 where XX is a _javascript_ reference to the value of texto4. 2006/1/19, Enrique Medina [EMAIL PROTECTED] mailto:
[EMAIL PROTECTED]: Let me give a more detailed explanation of what I am trying to achieve.. In my application I need to work with data in a spreadsheet form, so
 I decided to use a PanelTabbed component, where each tab would contain a HtmlDataTable. All these would simulate an Excel page, where I can change the actual tab, make some modifications to the
 elements in the table, go to another tab, modify, etc, so at the end I would press the save button, and all the changes would be persisted to the DB. The big problem I had with defining this page was the fact that all
 the data that was used to populate the tables in each tab was not known at compile time, as it depended on the values entered by the user during the normal use of the application.
 So I had to create all the components dynamically through Java code. To accomplish this objective, I created a JSP file with simply a PanelTabbed tag that I binded to a property in my backing bean, so
 whenever JSF called my setBindedTabbedPane method, I could create all the tabs, tables, labels, inputs, etc, in code. Once done, everything was perfect, in the sense that my application
 was implemented to dynamically create all the components needed to simulate an Excel worksheet; i.e. dynamic number of columns and rows, dynamic number of tabs, etc. On the other hand, I have also added DWR to my application in order
 to use Ajax for particular purposes, like showing child data in a datatable, or simply validate some specific fields without having to make a JSF request. So I decided to add a DWR Ajax validate process
 to my recently created Excel worksheet. But the problem comes because when using DWR Ajax, I need to define a callback function in _javascript_ where I have to pass as a parameter the value that I want to be validated. As you already
 know, I am generating all the components dynamically in code, within a loop that reuses temporal variable names for the sake of performance and clearness. This means that I use the
 FacesContext.getApplication().createComponent() to create every component, but reusing the same variable in the loop, as I don't know how many components will I have to create (i.e. how many inputs
 or datatables or tabs). To better clarify, imagine that I want to add a _javascript_ call in the onclick method of an input text box. When creating the component dynamically, I could do:
 UIInput texto4 = (HtmlInputText) FacesUtils.getApplication() .createComponent(HtmlInputText.COMPONENT_TYPE); texto4.getAttributes
().put(styleClass, txt); texto4 .setValueBinding( rendered, FacesUtils
 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones[' + codigoGrupo + '].puntuacionColumna
 != null})); texto4 .setValueBinding( value, FacesUtils
 .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones[' + codigoGrupo +
 '].puntuacionColumna})); Please notice that this piece of code will be executed for each input text box that is needed. If I set the Id with: 
texto4.setId(_input); Then this ID will be used as the last part of the HTML generated ID when rendering the page, so there is no way to know it when writing this code in the backing bean.
 So in the end, my question was about how could I know that ID at runtime. I mean, I can use EL to bind values with my objects' properties, but could I also do something similar with component
 attributes? 2006/1/19, Volker Weber [EMAIL PROTECTED] mailto:
[EMAIL PROTECTED]: Hi, Enrique Medina wrote: But I don't want to inject another bean. When I talk about components I
 mean view components in the model component; e.g. refer to an 

Re: Dynamically refer to a component from another component

2006-01-19 Thread Volker Weber
After adding the component to the component tree the full id should
returned. The structure of the tree is needed to create this id.
This is what is done when rendering the 'htlmId' in the renderer.

Without the tree structue there is no way to find the resulting clientId.

Regards,
  Volker

Enrique Medina wrote:
 I tried that, but at the time of creating the component in code,
 texto4.getClientId(facesContext) returns exactly the same used before
 when texto4.setId(_input), so it doesn't help at all
 
 2006/1/19, Volker Weber [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]:
 
 Hi,
 
 you can get the rendered 'htmlId' of a component by
   component.getCientId(facesContext);
 
 so you can do :
 
   UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication()
  .createComponent( HtmlOutputText.COMPONENT_TYPE);
 
   texto5.getAttributes().put(onclick,
   validate(' + texto4.getClientId(facesContext) + '));
 
 Regards,
   Volker
 
 Enrique Medina wrote:
  Also I forgot to say, that if I wanted to use the onclick method
 on the
  same UIInput component, I could define it easily by:
 
   texto4.getAttributes().put(onclick, validate( this.value));
 
  As you can see, I know that 'this' refers to my component. But what
  happens if I need to refer to texto4 component value from another
  component. Imagine:
 
  UIOutput texto5 = (HtmlOutputText)
 FacesUtils.getApplication()
  .createComponent(HtmlOutputText.COMPONENT_TYPE);
 
  texto5.getAttributes().put(onclick, validate(XX));
 
  where XX is a Javascript reference to the value of texto4.
 
 
  2006/1/19, Enrique Medina [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
  mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]:
 
  Let me give a more detailed explanation of what I am trying to
 achieve..
 
  In my application I need to work with data in a spreadsheet
 form, so
  I decided to use a PanelTabbed component, where each tab would
  contain a HtmlDataTable. All these would simulate an Excel page,
  where I can change the actual tab, make some modifications to the
  elements in the table, go to another tab, modify, etc, so at
 the end
  I would press the save button, and all the changes would be
  persisted to the DB.
 
  The big problem I had with defining this page was the fact
 that all
  the data that was used to populate the tables in each tab was not
  known at compile time, as it depended on the values entered by the
  user during the normal use of the application.
 
  So I had to create all the components dynamically through Java
 code.
  To accomplish this objective, I created a JSP file with simply a
  PanelTabbed tag that I binded to a property in my backing
 bean, so
  whenever JSF called my setBindedTabbedPane method, I could create
  all the tabs, tables, labels, inputs, etc, in code.
 
  Once done, everything was perfect, in the sense that my
 application
  was implemented to dynamically create all the components needed to
  simulate an Excel worksheet; i.e. dynamic number of columns and
  rows, dynamic number of tabs, etc.
 
  On the other hand, I have also added DWR to my application in
 order
  to use Ajax for particular purposes, like showing child data in a
  datatable, or simply validate some specific fields without
 having to
  make a JSF request. So I decided to add a DWR Ajax validate
 process
  to my recently created Excel worksheet.
 
  But the problem comes because when using DWR Ajax, I need to
 define
  a callback function in Javascript where I have to pass as a
  parameter the value that I want to be validated. As you already
  know, I am generating all the components dynamically in code,
 within
  a loop that reuses temporal variable names for the sake of
  performance and clearness. This means that I use the
  FacesContext.getApplication().createComponent() to create every
  component, but reusing the same variable in the loop, as I don't
  know how many components will I have to create (i.e. how many
 inputs
  or datatables or tabs).
 
  To better clarify, imagine that I want to add a Javascript call in
  the onclick method of an input text box. When creating the
 component
  dynamically, I could do:
 
  UIInput texto4 = (HtmlInputText)
 FacesUtils.getApplication()
 
 .createComponent(HtmlInputText.COMPONENT_TYPE);
 
  texto4.getAttributes ().put(styleClass, txt);
   

Re: Dynamically refer to a component from another component

2006-01-19 Thread Enrique Medina
So your answer means that there is no way to accomplish what I am trying, isn't it?Maybe using some kind of events, when the component is created to advise another one or so?2006/1/19, Volker Weber 
[EMAIL PROTECTED]:
After adding the component to the component tree the full id shouldreturned. The structure of the tree is needed to create this id.This is what is done when rendering the 'htlmId' in the renderer.Without the tree structue there is no way to find the resulting clientId.
Regards,VolkerEnrique Medina wrote: I tried that, but at the time of creating the component in code, texto4.getClientId(facesContext) returns exactly the same used before when 
texto4.setId(_input), so it doesn't help at all 2006/1/19, Volker Weber [EMAIL PROTECTED] mailto:
[EMAIL PROTECTED]: Hi, you can get the rendered 'htmlId' of a component by component.getCientId(facesContext); so you can do :
 UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication().createComponent( HtmlOutputText.COMPONENT_TYPE); texto5.getAttributes().put(onclick,
 validate(' + texto4.getClientId(facesContext) + ')); Regards, Volker Enrique Medina wrote:  Also I forgot to say, that if I wanted to use the onclick method
 on the  same UIInput component, I could define it easily by:  texto4.getAttributes().put(onclick, validate( this.value)); 
  As you can see, I know that 'this' refers to my component. But what  happens if I need to refer to texto4 component value from another  component. Imagine:
   UIOutput texto5 = (HtmlOutputText) FacesUtils.getApplication()  .createComponent(HtmlOutputText.COMPONENT_TYPE); 
  texto5.getAttributes().put(onclick, validate(XX));   where XX is a _javascript_ reference to the value of texto4. 
   2006/1/19, Enrique Medina [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  mailto: 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]:   Let me give a more detailed explanation of what I am trying to
 achieve..   In my application I need to work with data in a spreadsheet form, so  I decided to use a PanelTabbed component, where each tab would
  contain a HtmlDataTable. All these would simulate an Excel page,  where I can change the actual tab, make some modifications to the  elements in the table, go to another tab, modify, etc, so at
 the end  I would press the save button, and all the changes would be  persisted to the DB.   The big problem I had with defining this page was the fact
 that all  the data that was used to populate the tables in each tab was not  known at compile time, as it depended on the values entered by the  user during the normal use of the application.
   So I had to create all the components dynamically through Java code.  To accomplish this objective, I created a JSP file with simply a  PanelTabbed tag that I binded to a property in my backing
 bean, so  whenever JSF called my setBindedTabbedPane method, I could create  all the tabs, tables, labels, inputs, etc, in code.   Once done, everything was perfect, in the sense that my
 application  was implemented to dynamically create all the components needed to  simulate an Excel worksheet; i.e. dynamic number of columns and  rows, dynamic number of tabs, etc.
   On the other hand, I have also added DWR to my application in order  to use Ajax for particular purposes, like showing child data in a  datatable, or simply validate some specific fields without
 having to  make a JSF request. So I decided to add a DWR Ajax validate process  to my recently created Excel worksheet.   But the problem comes because when using DWR Ajax, I need to
 define  a callback function in _javascript_ where I have to pass as a  parameter the value that I want to be validated. As you already  know, I am generating all the components dynamically in code,
 within  a loop that reuses temporal variable names for the sake of  performance and clearness. This means that I use the  FacesContext.getApplication
().createComponent() to create every  component, but reusing the same variable in the loop, as I don't  know how many components will I have to create (i.e. how many inputs
  or datatables or tabs).   To better clarify, imagine that I want to add a _javascript_ call in  the onclick method of an input text box. When creating the
 component  dynamically, I could do:   UIInput texto4 = (HtmlInputText) FacesUtils.getApplication()  .createComponent(
HtmlInputText.COMPONENT_TYPE);   texto4.getAttributes ().put(styleClass, txt);  texto4  .setValueBinding(
  rendered,  FacesUtils   .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones
['  + codigoGrupo  + '].puntuacionColumna  != null}));
  texto4  .setValueBinding(  value,  FacesUtils
   .getValueBinding(#{puntuacionesBean.mapaScoreboardPuntuaciones['  + codigoGrupo  +
  '].puntuacionColumna}));   Please notice that this piece of code will be executed for each  input text box that is needed. If I set the Id with:
   texto4.setId(_input);   Then this ID will be used as the last part of the HTML generated ID  when rendering the 

Re: Dynamically refer to a component from another component

2006-01-19 Thread Simon Kitching
I believe Volker's answer is exactly what you're looking for. Unless
I've misunderstood your question, method getClientId is what you want;
you just need to make sure the component is attached to the view tree
before calling that method.

ie:

  UIOutput texto4 = createComponent(..);
  texto4.setId(texto4);

  // parent is expected to already be attached to the view tree.
  parent.getChildren().add(texto4);

  // do this only after adding to view tree. You'll then get the 
  // full final id of the component, eg form1:subview1:table3:texto4
  String texto4ClientId = texto4.getClientId(facesContext);

  // use texto4ClientId in javascript emitted for some other component

If you need to find the texto4 client from some other renderer, you
can search for it:
  
  UIOutput text05 = createComponent(..);

  // find a component with the specified name within the same
  // naming container as the component the find is invoked on
  UIOutput targetComponent = parent.findComponent(texto4);

  String targetClientId = targetComponent.getClientId();
  // use targetClientId in javascript emitted for texto5 component
  

Note also that component ids starting with underscores are reserved for
the use of the JSF framework; any id you assign explicitly should *not*
start with an underscore.

Regards,

Simon

On Thu, 2006-01-19 at 16:49 +0100, Enrique Medina wrote:
 See what is generated at runtime:
 
 input id=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input 
 name=bodySubview:_id23:tablaEdicionPuntuaciones0_1:_id24_4_0:_input type=
 text value=12 onclick=myAlert(_input.value) 
 class=txt /
 
 And obviously, a component with _input ID does not exist, because as
 being contained, the ID generated for the input component is
 different... 
 
 2006/1/19, Volker Weber [EMAIL PROTECTED]:
 Hi,
 
 you can get the rendered 'htmlId' of a component by
   component.getCientId(facesContext);
 
 so you can do :
 
   UIOutput texto5 = (HtmlOutputText)
 FacesUtils.getApplication()
  .createComponent( HtmlOutputText.COMPONENT_TYPE);
 
   texto5.getAttributes().put(onclick,
   validate(' + texto4.getClientId(facesContext) + '));
 
 Regards,
   Volker
 
 Enrique Medina wrote: 
  Also I forgot to say, that if I wanted to use the onclick
 method on the
  same UIInput component, I could define it easily by:
 
   texto4.getAttributes().put(onclick,
 validate( this.value));
 
  As you can see, I know that 'this' refers to my component.
 But what
  happens if I need to refer to texto4 component value from
 another
  component. Imagine:
 
  UIOutput texto5 = (HtmlOutputText)
 FacesUtils.getApplication()
  .createComponent(HtmlOutputText.COMPONENT_TYPE);
 
  texto5.getAttributes().put(onclick,
 validate(XX)); 
 
  where XX is a Javascript reference to the value of
 texto4.
 
 
  2006/1/19, Enrique Medina [EMAIL PROTECTED]
  mailto: [EMAIL PROTECTED]:
 
  Let me give a more detailed explanation of what I am
 trying to achieve..
 
  In my application I need to work with data in a
 spreadsheet form, so 
  I decided to use a PanelTabbed component, where each tab
 would
  contain a HtmlDataTable. All these would simulate an
 Excel page,
  where I can change the actual tab, make some
 modifications to the 
  elements in the table, go to another tab, modify, etc,
 so at the end
  I would press the save button, and all the changes would
 be
  persisted to the DB.
 
  The big problem I had with defining this page was the
 fact that all 
  the data that was used to populate the tables in each
 tab was not
  known at compile time, as it depended on the values
 entered by the
  user during the normal use of the application.
  
  So I had to create all the components dynamically
 through Java code.
  To accomplish this objective, I created a JSP file with
 simply a
  PanelTabbed tag that I binded to a property in my
 backing bean, so 
  whenever JSF called my setBindedTabbedPane method, I
 could create
  all the tabs, tables, labels, inputs, etc, in code.
 
  Once done, everything was perfect, in the sense that my
 application 
  was implemented to dynamically create all the components
 needed to
  simulate an Excel worksheet; i.e. 

RE: Dynamically refer to a component from another component

2006-01-19 Thread Jesse Alexander \(KBSA 21\)



No he says: You need to add the component to its parent 
component before you can receive a 
usefull clientId.

hthAlexander


From: Enrique Medina 
[mailto:[EMAIL PROTECTED] Sent: Thursday, January 19, 2006 5:12 
PMTo: MyFaces DiscussionSubject: Re: Dynamically refer to 
a component from another component
So your answer means that there is no way to accomplish what I am 
trying, isn't it?Maybe using some kind of events, when the component is 
created to advise another one or so?
2006/1/19, Volker Weber  [EMAIL PROTECTED]:
After 
  adding the component to the component tree the full id shouldreturned. The 
  structure of the tree is needed to create this id.This is what is done 
  when rendering the 'htlmId' in the renderer.Without the tree structue 
  there is no way to find the resulting clientId. 
  Regards,VolkerEnrique Medina wrote: I 
  tried that, but at the time of creating the component in code, 
  texto4.getClientId(facesContext) returns exactly the same used before 
  when texto4.setId("_input"), so it doesn't help at all 
  2006/1/19, Volker Weber [EMAIL PROTECTED] 
  mailto: 
  [EMAIL PROTECTED]: 
  Hi, you can get the rendered 'htmlId' 
  of a component by 
  component.getCientId(facesContext); so 
  you can do :  UIOutput 
  texto5 = (HtmlOutputText) 
  FacesUtils.getApplication().createComponent( 
  HtmlOutputText.COMPONENT_TYPE); 
  texto5.getAttributes().put("onclick", 
   
  "validate('" + texto4.getClientId(facesContext) + 
  "')"); 
  Regards, 
  Volker Enrique Medina 
  wrote:  Also I forgot to say, that if I 
  wanted to use the onclick method  on 
  the  same UIInput component, I could 
  define it easily by: 
   
  texto4.getAttributes().put("onclick", 
  "validate( this.value)");  
As you can see, I know that 'this' 
  refers to my component. But what  happens 
  if I need to refer to "texto4" component value from 
  another  component. 
  Imagine:  
   
  UIOutput texto5 = (HtmlOutputText) 
  FacesUtils.getApplication() 
   
  .createComponent(HtmlOutputText.COMPONENT_TYPE); 
   
   
  texto5.getAttributes().put("onclick", 
  validate(XX)); 
where XX is a _javascript_ 
  reference to the value of "texto4". 
 
  2006/1/19, Enrique Medina [EMAIL PROTECTED] 
  mailto:[EMAIL PROTECTED] 
   mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]: 
Let me give 
  a more detailed explanation of what I am trying to 
   achieve.. 
In my 
  application I need to work with data in a 
  spreadsheet form, 
  so  I decided to 
  use a PanelTabbed component, where each tab would 
contain a 
  HtmlDataTable. All these would simulate an Excel 
  page,  where I can 
  change the actual tab, make some modifications to 
  the  elements in 
  the table, go to another tab, modify, etc, so at 
   the end 
   I would press the save button, and all the 
  changes would be  
  persisted to the DB. 
The big 
  problem I had with defining this page was the fact 
   that all 
   the data that was used to populate the tables in 
  each tab was not  
  known at compile time, as it depended on the values entered by 
  the  user during 
  the normal use of the application.  
So I had to 
  create all the components dynamically through 
  Java code. 
   To accomplish this objective, I created a JSP 
  file with simply a 
   PanelTabbed tag that I binded to a property in my 
  backing  bean, 
  so  whenever JSF 
  called my setBindedTabbedPane method, I could 
  create  all the 
  tabs, tables, labels, inputs, etc, in code. 
Once done, 
  everything was perfect, in the sense that my  
  application  was 
  implemented to dynamically create all the components needed 
  to  simulate an 
  Excel worksheet; i.e. dynamic number of columns 
  and  rows, dynamic 
  number of tabs, etc.  
On the other 
  hand, I have also added DWR to my application 
  in order 
   to use Ajax for particular purposes, like showing 
  child data in a  
  datatable, or simply validate some specific fields without 
   having to 
   make a JSF request. So I decided to add a DWR 
  Ajax validate 
  process  to my 
  recently created Excel worksheet. 
But the 
  problem comes because when using DWR Ajax, I need to 
   define 
   a callback function in _javascript_ where I have to 
  pass as a  
  parameter the value that I want to be validated. As you 
  already  know, I 
  am generating all the components dynamically in code, 
   within 
   a loop that reuses temporal variable names for 
  the sake of  
  performance and clearness. This means that I use 
  the  
  FacesContext.getApplication ().createComponent() to create 
  every  component, 
  but reusing the same variable in the loop, as I 
  don't  know how 
  many components will I have to create (i.e. how 
  many inputs  
   or datatables or 
  tabs).  
   To better clarify, imagine that I want to add a 
  _javascript_ call in 
   the onclick m