List Info

Thread: : how to get the id of the current element to pass it to a function




: how to get the id of the current element to pass it to a function
user name
2007-10-08 09:04:59
Hi Tobago friends,
 
I have a question for all JSF users (th'at's why I wrote +obago for those who have filters). I'd like to let each user choose what he wants displayed in his/her label and link fields. So I wrote a function that I'd like to call this way for example:
 

 &nbsp; &nbsp; &nbsp; &nbsp;   ; <tc:column >

 &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   < tc:link label ="#{itf:toString(contract.client, 'xxxx' )}"></ tc:link>

 &nbsp; &nbsp;   ; &nbsp; &nbsp; </tc:column >

 



Where I'd like to have in xxxx the id of the current element.&nbsp; Does anyone have a solution to insert it automatically through javascript or an el expression?
&nbsp;
I think javascript could be a good candidte sth like
 
function( tag ) {
 ; return tag.id;
}
&nbsp;
But I'm really bad in js, I don't know when it gets called, how to call it to fill in the value at page load, and fetures like that...
 
I'd be very happy if someone can help.
&nbsp;
Cheers and folks,
Zied
AW: : how to get the id of the current element to pass it to a function
country flaguser name
Germany
2007-10-08 09:38:41

Hi Zied,

 

I think the tag <tc:script/> is the solution. It has several attributes like “onload” or “onexit”. You should place it inside <tc:page>. Here a skeleton:

 

<f:view>

 <script language=&#8221;javascript”;>

            function doIt(){

                        alert(R20;Welcome&#8221;);

            }

 </script>

 <tc:page>

  <tc:script onload=221;doIt()&#8221;/>

  …your content230;

 </tc:page>

</f:view>

 

Hope it helps.

 

Regards, Mario

 


Von: Zied Hamdi [mailto:javahamdigmail.com]
Gesendet: Montag, 8. Oktober 2007 16:05
An: MyFaces
Betreff: [JSF] and maybe [+obago] : how to get the id of the current element to pass it to a function

 

Hi Tobago friends,

 

I have a question for all JSF users (th'at's why I wrote +obago for those who have filters). I'd like to let each user choose what he wants displayed in his/her label and link fields. So I wrote a function that I'd like to call this way for example:

 

             <tc:column >

                  < tc:link label ="#{itf:toString(contract.client, 'xxxx' )}"></ tc:link>

            </tc:column >

 



Where I'd like to have in xxxx the id of the current element.&nbsp; Does anyone have a solution to insert it automatically through javascript or an el expression?

 

I think javascript could be a good candidte sth like

 

function(&nbsp;tag ) {

  return tag.id;

}

 

But I'm really bad in js, I don't know when it gets called, how to call it to fill in the value at page load, and fetures like that...

 

I'd be very happy if someone can help.

 

Cheers and folks,

Zied

Re: : how to get the id of the current element to pass it to a function
user name
2007-10-08 09:46:42
Hi Mario,
 
Thanks!!! that's great to know. I'll try to search the document for xxxx and replace with the element id.
 
Though&nbsp;I prefer to let this solution as the no solution approch, In fact I planned to do my own xx:link and xx:label that gets its own id and pass it transaparently with no impact on the owning page...
 
Anyway it's a great thing to know in general.
 
Regards,
Zied

&nbsp;
2007/10/8, Schröder, Mario < mario.schroedersaxsys.de">mario.schroedersaxsys.de>:

Hi Zied,

 

I think the tag <tc:script/> is the solution. It has several attributes like "onload" or "onexit". You should place it inside <tc:page>. Here a skeleton:

 

<f:view>

 <script language="javascript">

 &nbsp; &nbsp; &nbsp; &nbsp;   ; function doIt(){

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  alert("Welcome");

 &nbsp; &nbsp; &nbsp; &nbsp;   ; }

 </script>

 <tc:page>

  <tc:script onload="doIt()"/>

  …your content…

 </tc:page>;

</f:view>

 

Hope it helps.

 

Regards, Mario

 


Von: Zied Hamdi [mailto: gmail.com" target="_blank">javahamdigmail.com]
Gesendet: Montag, 8. Oktober 2007 16:05
An: MyFaces
Betreff: [JSF] and maybe [+obago] : how to get the id of the current element to pass it to a function

 

Hi Tobago friends,

 

I have a question for all JSF users (th'at's why I wrote +obago for those who have filters). I'd like to let each user choose what he wants displayed in his/her label and link fields. So I wrote a function that I'd like to call this way for example:

 

 &nbsp; &nbsp; &nbsp; &nbsp;   ;  &lt;tc:column >

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; < tc:link label = "#{itf:toString(contract.client, ' xxxx' )}"></ tc:link>

 &nbsp; &nbsp; &nbsp; &nbsp;   ; </tc:column >

 



Where I'd like to have in xxxx the id of the current element.&nbsp; Does anyone have a solution to insert it automatically through javascript or an el expression?

 

I think javascript could be a good candidte sth like

 

function(&nbsp;tag ) {

  return tag.id;

}

 

But I'm really bad in js, I don't know when it gets called, how to call it to fill in the value at page load, and fetures like that...

 

I'd be very happy if someone can help.

 

Cheers and folks,

Zied




--
Zied Hamdi
zatreex.sourceforge.net
Re: : how to get the id of the current element to pass it to a function
country flaguser name
Sweden
2007-10-08 09:43:54
On Mon, 2007-10-08 at 16:04 +0200, Zied Hamdi wrote:
> Hi Tobago friends,
>  
> I have a question for all JSF users (th'at's why I
wrote +obago for
> those who have filters). I'd like to let each user
choose what he
> wants displayed in his/her label and link fields. So I
wrote a
> function that I'd like to call this way for example:
>  
>             <tc:column>
> 
>                   <tc:link
label="#{itf:toString(contract.client,
> 'xxxx' )}"></tc:link>
> 
>             </tc:column>
> 
>  
> 
> 
> 
> Where I'd like to have in xxxx the id of the current
element.  Does
> anyone have a solution to insert it automatically
through javascript
> or an el expression?
>  
> I think javascript could be a good candidte sth like 
>  
> function( tag ) {
>   return tag.id;
> }
>  
> But I'm really bad in js, I don't know when it gets
called, how to
> call it to fill in the value at page load, and fetures
like that...

What exactly are you trying to achieve?

Are you intending to have a database of (labelid, text) per
user on the
server side, and using this table to generate
different-looking html
output for each user?

Or are you going to somehow have a big javascript hashmap on
the client
side with (labelid, text) pairs that you use to post-process
the page
after it has been returned to the browser?

In either case, how is the user going to specify what text
they want?

Or do you mean something else?

Regards,

Simon



Re: : how to get the id of the current element to pass it to a function
user name
2007-10-08 09:58:40
Hi Simon,
 
I have a Facelets function wich will act on the server side:
&nbsp; - each user will be able to have its rows in database for specifying the pattern he want to have for a given id
 
For example&nbsp;let's say the pattern is simply an el expression:
  whan I use my facelets tag xx:link it gets the id of the tc:link element it contains and passes it to the facelets function. This one gets the corresponding el expression and returns&nbsp;the resulting&nbsp;string of itf:toString(contract.client, 'correspondingEl'
 
where correspondingEl is for example: "#{client.lastName} entred: #{client.entryDate}&quot; for the user1
and "#{client.lastName} sponsored #{client.sponsored.size}" for user2, both expressions will be in database under the key : "JSF id of the link"
 
For me it's important that this happens as transparently as using a standard tag. The content of the template tag can contain js code naturally, but it inspects alone the id of its content.
 
Regards,
Zied
&nbsp;

&nbsp;
2007/10/8, Zied Hamdi < javahamdigmail.com">javahamdigmail.com>:
Hi Mario,
 
Thanks!!! that's great to know. I'll try to search the document for xxxx and replace with the element id.
 
Though&nbsp;I prefer to let this solution as the no solution approch, In fact I planned to do my own xx:link and xx:label that gets its own id and pass it transaparently with no impact on the owning page...
 
Anyway it's a great thing to know in general.
 
Regards,
Zied

&nbsp;
2007/10/8, Schröder, Mario <saxsys.de" target="_blank">mario.schroedersaxsys.de>:

Hi Zied,

 

I think the tag <tc:script/> is the solution. It has several attributes like "onload" or "onexit". You should place it inside <tc:page>. Here a skeleton:

 

<f:view>

 <script language=&quot;javascript"&gt;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; function doIt(){

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  alert(&quot;Welcome&quot;);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; }

 </script>

 <tc:page>

  <tc:script onload=&quot;doIt()&quot;/>

  …your content…

 </tc:page>;

</f:view>

 

Hope it helps.

 

Regards, Mario

 


Von: Zied Hamdi [mailto: gmail.com" target="_blank">javahamdigmail.com]
Gesendet: Montag, 8. Oktober 2007 16:05
An: MyFaces
Betreff: [JSF] and maybe [+obago] : how to get the id of the current element to pass it to a function

 

Hi Tobago friends,

 

I have a question for all JSF users (th'at's why I wrote +obago for those who have filters). I'd like to let each user choose what he wants displayed in his/her label and link fields. So I wrote a function that I'd like to call this way for example:

 

 &nbsp; &nbsp; &nbsp; &nbsp;   ;  &lt;tc:column >

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; < tc:link label = "#{itf:toString(contract.client, ' xxxx' )}"></ tc:link>

 &nbsp; &nbsp; &nbsp; &nbsp;   ; </tc:column >

 



Where I'd like to have in xxxx the id of the current element.&nbsp; Does anyone have a solution to insert it automatically through javascript or an el expression?

 

I think javascript could be a good candidte sth like

 

function(&nbsp;tag ) {

  return tag.id;

}

 

But I'm really bad in js, I don't know when it gets called, how to call it to fill in the value at page load, and fetures like that...

 

I'd be very happy if someone can help.

 

Cheers and folks,

Zied




--
Zied Hamdi
zatreex.sourceforge.net



--
Zied Hamdi
zatreex.sourceforge.net
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )