You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Rottstock, Sven" <Sv...@sungard.de> on 2007/12/21 13:55:02 UTC

[Trinidad] Override onclick Event

Hi list,

i have to dynamically override the onclick method. Currently i used the
following code snippet:

<script>
  var completeBtn =
window.document.getElementById("activityPanel:activityActionPane:complet
e-button");
  var oldOnClickMethod = null;
  if(completeBtn != null)
  {
    oldOnclickMethod = completeBtn.onclick;
    completeBtn.onclick = doMyAction;
  }
  function doMyAction() {
     // perform additional tasks here...
     // ...
     // ...
     oldOnClickMethod();
  }
</script>

I cannot imagine that this solution is the best way (but it works for
me)...have anybody a hint for me how i can do that in a "Trinidad way"?

Regards,

Sven

AW: [Trinidad] Override onclick Event

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Ok - i have tested it. The decoration page looks as follow:
 
<!-- decoration page -->
<ui:composition>
  <script>
    function myCompleteMethod() { alert('completed'); }
  </script>
  <ui:decorate template="template.xhtml">
    <ui:define name="onComplete" value="myCompleteMethod()"/>
  </ui:decorate>
</ui:compsition>
<!-- end decoration page -->
 
Now it works great. Thank you for the pointer.
 
Regards,
 
Sven

________________________________

Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de] 
Gesendet: Freitag, 21. Dezember 2007 16:07
An: MyFaces Discussion
Betreff: AW: [Trinidad] Override onclick Event


Good pointer. If i understand you correctly then this should be the best
practice for my requirement:

<!-- template page -->
<ui:composition>
  <!-- some code before... -->
  <tr:commandLink id="completeLink" onclick=#{onComplete}/>
  <!-- some code behind... -->
</ui:compsition>
<!-- end template page -->
 
<!-- decoration page -->
<ui:composition>
  <trh:script text="function myCompleteMethod { alert('completed'); }"/>
  <c:set value="myCompleteMethod" var="onComplete" scope="page"/>
  <ui:decorate template="template.xhtml">
  </ui:decorate>
</ui:compsition>
<!-- end decoration page -->
 
Looks very simple. Great job Simon. Thank you.
 
Regards
 
Sven
 
________________________________

Von: Simon Lessard [mailto:simon.lessard.3@gmail.com] 
Gesendet: Freitag, 21. Dezember 2007 15:10
An: MyFaces Discussion
Betreff: Re: [Trinidad] Override onclick Event


Then one way would be to define the script in the user page and
reference it using EL from the template.


Regards,

~ Simon


On Dec 21, 2007 8:07 AM, Rottstock, Sven < Sven.Rottstock@sungard.de
<ma...@sungard.de> > wrote:


	Hi Simon,
	 
	we provide a specific page for our customer. He can decorate
this page via facelets and IMO it is a bad idea to modify the specific
page. Because we can change the content of the specific page and the
customer has the effort to merge.
	 
________________________________

	Von: Simon Lessard [mailto:simon.lessard.3@gmail.com] 
	Gesendet: Freitag, 21. Dezember 2007 13:58
	An: MyFaces Discussion
	Betreff: Re: [Trinidad] Override onclick Event
	
	
	Hi Sven,
	
	Why not use the onclick attribute on the component?
	
	
	Regards,
	
	~ Simon
	
	
	On Dec 21, 2007 7:55 AM, Rottstock, Sven <
Sven.Rottstock@sungard.de <ma...@sungard.de> > wrote:
	

		Hi list,
		
		i have to dynamically override the onclick method.
Currently i used the 
		following code snippet:
		
		<script>
		 var completeBtn =
	
window.document.getElementById("activityPanel:activityActionPane:complet
		e-button");
		 var oldOnClickMethod = null;
		 if(completeBtn != null) 
		 {
		   oldOnclickMethod = completeBtn.onclick;
		   completeBtn.onclick = doMyAction;
		 }
		 function doMyAction() {
		    // perform additional tasks here...
		    // ...
		    // ...
		    oldOnClickMethod(); 
		 }
		</script>
		
		I cannot imagine that this solution is the best way (but
it works for
		me)...have anybody a hint for me how i can do that in a
"Trinidad way"?
		
		Regards,
		
		Sven
		




AW: [Trinidad] Override onclick Event

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Good pointer. If i understand you correctly then this should be the best
practice for my requirement:

<!-- template page -->
<ui:composition>
  <!-- some code before... -->
  <tr:commandLink id="completeLink" onclick=#{onComplete}/>
  <!-- some code behind... -->
</ui:compsition>
<!-- end template page -->
 
<!-- decoration page -->
<ui:composition>
  <trh:script text="function myCompleteMethod { alert('completed'); }"/>
  <c:set value="myCompleteMethod" var="onComplete" scope="page"/>
  <ui:decorate template="template.xhtml">
  </ui:decorate>
</ui:compsition>
<!-- end decoration page -->
 
Looks very simple. Great job Simon. Thank you.
 
Regards
 
Sven
 
________________________________

Von: Simon Lessard [mailto:simon.lessard.3@gmail.com] 
Gesendet: Freitag, 21. Dezember 2007 15:10
An: MyFaces Discussion
Betreff: Re: [Trinidad] Override onclick Event


Then one way would be to define the script in the user page and
reference it using EL from the template.


Regards,

~ Simon


On Dec 21, 2007 8:07 AM, Rottstock, Sven < Sven.Rottstock@sungard.de
<ma...@sungard.de> > wrote:


	Hi Simon,
	 
	we provide a specific page for our customer. He can decorate
this page via facelets and IMO it is a bad idea to modify the specific
page. Because we can change the content of the specific page and the
customer has the effort to merge.
	 
________________________________

	Von: Simon Lessard [mailto:simon.lessard.3@gmail.com] 
	Gesendet: Freitag, 21. Dezember 2007 13:58
	An: MyFaces Discussion
	Betreff: Re: [Trinidad] Override onclick Event
	
	
	Hi Sven,
	
	Why not use the onclick attribute on the component?
	
	
	Regards,
	
	~ Simon
	
	
	On Dec 21, 2007 7:55 AM, Rottstock, Sven <
Sven.Rottstock@sungard.de <ma...@sungard.de> > wrote:
	

		Hi list,
		
		i have to dynamically override the onclick method.
Currently i used the 
		following code snippet:
		
		<script>
		 var completeBtn =
	
window.document.getElementById("activityPanel:activityActionPane:complet
		e-button");
		 var oldOnClickMethod = null;
		 if(completeBtn != null) 
		 {
		   oldOnclickMethod = completeBtn.onclick;
		   completeBtn.onclick = doMyAction;
		 }
		 function doMyAction() {
		    // perform additional tasks here...
		    // ...
		    // ...
		    oldOnClickMethod(); 
		 }
		</script>
		
		I cannot imagine that this solution is the best way (but
it works for
		me)...have anybody a hint for me how i can do that in a
"Trinidad way"?
		
		Regards,
		
		Sven
		




Re: [Trinidad] Override onclick Event

Posted by Simon Lessard <si...@gmail.com>.
Then one way would be to define the script in the user page and reference it
using EL from the template.


Regards,

~ Simon

On Dec 21, 2007 8:07 AM, Rottstock, Sven <Sv...@sungard.de> wrote:

>  Hi Simon,
>
> we provide a specific page for our customer. He can decorate this page via
> facelets and IMO it is a bad idea to modify the specific page. Because we
> can change the content of the specific page and the customer has the effort
> to merge.
>
>  ------------------------------
>  *Von:* Simon Lessard [mailto:simon.lessard.3@gmail.com]
> *Gesendet:* Freitag, 21. Dezember 2007 13:58
> *An:* MyFaces Discussion
> *Betreff:* Re: [Trinidad] Override onclick Event
>
> Hi Sven,
>
> Why not use the onclick attribute on the component?
>
>
> Regards,
>
> ~ Simon
>
> On Dec 21, 2007 7:55 AM, Rottstock, Sven < Sven.Rottstock@sungard.de>
> wrote:
>
> > Hi list,
> >
> > i have to dynamically override the onclick method. Currently i used the
> > following code snippet:
> >
> > <script>
> >  var completeBtn =
> > window.document.getElementById("activityPanel:activityActionPane:complet
> > e-button");
> >  var oldOnClickMethod = null;
> >  if(completeBtn != null)
> >  {
> >    oldOnclickMethod = completeBtn.onclick;
> >    completeBtn.onclick = doMyAction;
> >  }
> >  function doMyAction() {
> >     // perform additional tasks here...
> >     // ...
> >     // ...
> >     oldOnClickMethod();
> >  }
> > </script>
> >
> > I cannot imagine that this solution is the best way (but it works for
> > me)...have anybody a hint for me how i can do that in a "Trinidad way"?
> >
> > Regards,
> >
> > Sven
> >
>
>

AW: [Trinidad] Override onclick Event

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Hi Simon,
 
we provide a specific page for our customer. He can decorate this page
via facelets and IMO it is a bad idea to modify the specific page.
Because we can change the content of the specific page and the customer
has the effort to merge.
 
________________________________

Von: Simon Lessard [mailto:simon.lessard.3@gmail.com] 
Gesendet: Freitag, 21. Dezember 2007 13:58
An: MyFaces Discussion
Betreff: Re: [Trinidad] Override onclick Event


Hi Sven,

Why not use the onclick attribute on the component?


Regards,

~ Simon


On Dec 21, 2007 7:55 AM, Rottstock, Sven < Sven.Rottstock@sungard.de
<ma...@sungard.de> > wrote:


	Hi list,
	
	i have to dynamically override the onclick method. Currently i
used the 
	following code snippet:
	
	<script>
	 var completeBtn =
	
window.document.getElementById("activityPanel:activityActionPane:complet
	e-button");
	 var oldOnClickMethod = null;
	 if(completeBtn != null) 
	 {
	   oldOnclickMethod = completeBtn.onclick;
	   completeBtn.onclick = doMyAction;
	 }
	 function doMyAction() {
	    // perform additional tasks here...
	    // ...
	    // ...
	    oldOnClickMethod(); 
	 }
	</script>
	
	I cannot imagine that this solution is the best way (but it
works for
	me)...have anybody a hint for me how i can do that in a
"Trinidad way"?
	
	Regards,
	
	Sven
	



Re: [Trinidad] Override onclick Event

Posted by Simon Lessard <si...@gmail.com>.
Hi Sven,

Why not use the onclick attribute on the component?


Regards,

~ Simon

On Dec 21, 2007 7:55 AM, Rottstock, Sven <Sv...@sungard.de> wrote:

> Hi list,
>
> i have to dynamically override the onclick method. Currently i used the
> following code snippet:
>
> <script>
>  var completeBtn =
> window.document.getElementById("activityPanel:activityActionPane:complet
> e-button");
>  var oldOnClickMethod = null;
>  if(completeBtn != null)
>  {
>    oldOnclickMethod = completeBtn.onclick;
>    completeBtn.onclick = doMyAction;
>  }
>  function doMyAction() {
>     // perform additional tasks here...
>     // ...
>     // ...
>     oldOnClickMethod();
>  }
> </script>
>
> I cannot imagine that this solution is the best way (but it works for
> me)...have anybody a hint for me how i can do that in a "Trinidad way"?
>
> Regards,
>
> Sven
>