Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-30 Thread Juan E. Maya
yep, i just checked and FLOT uses jQuery so that's the problem for sure.

On Thu, Jul 30, 2009 at 10:53 AM, Ciaran Wood wrote:
> I think the problem here is that the javascript that FLOT is expecting is
> clashing with the prototype javascript library that tapestry imports. When
> you use prototype, $ evaluates to a function that expects either a DOM
> element or the id of a DOM element. Does FLOT use jquery prehaps? If so, you
> might be able to get round this limitation by using jquery's noConflict
> mode.
>
> Ciaran
>
> On 30/07/2009 9:31am, "Juan E. Maya"  wrote:
>
>> Ignacio that's nothing related with tapestry. U should understand what
>> u r trying to achieve with ur javascript and do it. do u know what
>> does the $ symbol means before a function and why should that be used?
>>
>> The problem is not related tapestry.
>>
>> 2009/7/30 Ignacio González Arboleya :
>>> Now I can see the problem:
>>>
>>> I've tried to execute other kind of javascript codes and they work fine.
>>>
>>> The problem is that FLOT needs the following code to execute:
>>>
>>> $(function () {
>>>    var d1 = [];
>>>    for (var i = 0; i < 14; i += 0.5)
>>>        d1.push([i, Math.sin(i)]);
>>>
>>>    var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
>>>
>>>    // a null signifies separate line segments
>>>    var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
>>>
>>>    $.plot($("#placeholder"), [ d1, d2, d3 ]);
>>> });
>>> BUT tapestry automatically generates this:Tapestry.onDOMLoaded(function()
>>> {(.)}); WITHOUT THE SYMBOL $ before "function()" that is needed
>>> to execute FLOT... any ideas please
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-30 Thread Ciaran Wood
I think the problem here is that the javascript that FLOT is expecting is
clashing with the prototype javascript library that tapestry imports. When
you use prototype, $ evaluates to a function that expects either a DOM
element or the id of a DOM element. Does FLOT use jquery prehaps? If so, you
might be able to get round this limitation by using jquery's noConflict
mode.

Ciaran

On 30/07/2009 9:31am, "Juan E. Maya"  wrote:

> Ignacio that's nothing related with tapestry. U should understand what
> u r trying to achieve with ur javascript and do it. do u know what
> does the $ symbol means before a function and why should that be used?
> 
> The problem is not related tapestry.
> 
> 2009/7/30 Ignacio González Arboleya :
>> Now I can see the problem:
>> 
>> I've tried to execute other kind of javascript codes and they work fine.
>> 
>> The problem is that FLOT needs the following code to execute:
>> 
>> $(function () {
>>    var d1 = [];
>>    for (var i = 0; i < 14; i += 0.5)
>>        d1.push([i, Math.sin(i)]);
>> 
>>    var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
>> 
>>    // a null signifies separate line segments
>>    var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
>> 
>>    $.plot($("#placeholder"), [ d1, d2, d3 ]);
>> });
>> BUT tapestry automatically generates this:Tapestry.onDOMLoaded(function()
>> {(.)}); WITHOUT THE SYMBOL $ before "function()" that is needed
>> to execute FLOT... any ideas please
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-30 Thread Juan E. Maya
Ignacio that's nothing related with tapestry. U should understand what
u r trying to achieve with ur javascript and do it. do u know what
does the $ symbol means before a function and why should that be used?

The problem is not related tapestry.

2009/7/30 Ignacio González Arboleya :
> Now I can see the problem:
>
> I've tried to execute other kind of javascript codes and they work fine.
>
> The problem is that FLOT needs the following code to execute:
>
> $(function () {
>    var d1 = [];
>    for (var i = 0; i < 14; i += 0.5)
>        d1.push([i, Math.sin(i)]);
>
>    var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
>
>    // a null signifies separate line segments
>    var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
>
>    $.plot($("#placeholder"), [ d1, d2, d3 ]);
> });
> BUT tapestry automatically generates this:Tapestry.onDOMLoaded(function() 
> {(.)}); WITHOUT THE SYMBOL $ before "function()" that is needed 
> to execute FLOT... any ideas please

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-29 Thread Ignacio González Arboleya
Now I can see the problem:

I've tried to execute other kind of javascript codes and they work fine.

The problem is that FLOT needs the following code to execute:

$(function () {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);

var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];

// a null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];

$.plot($("#placeholder"), [ d1, d2, d3 ]);
});
BUT tapestry automatically generates this:Tapestry.onDOMLoaded(function() 
{(.)}); WITHOUT THE SYMBOL $ before "function()" that is needed to 
execute FLOT... any ideas please

Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-29 Thread Juan E. Maya
so ur adding the javascript :)

This piece of code tells tapestry to add the javascript:

   renderSupport.addScript(

" var d1 = [];" +
" for (var i = 0; i < 14; i += 0.5)"+
"d1.push([i, Math.sin(i)]);"+

 "var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];"+


 "var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];"+

 "$.plot($(\"#placeholder\"), [ d1, d2, d3 ]);"




   );

if u remove that the js will not be generated.
I recommend u to check the wiki page:
http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained to
understand what's going on



2009/7/29 Ignacio González Arboleya :
> This is what I have:
>
> class "ShowMediciones.java":
> _
> package com.mundor.internet.interfazweb.web.pages.monitorizacion;
>
>
> import java.text.DateFormat;
> import java.util.List;
> import java.util.Locale;
>
> import org.apache.tapestry5.RenderSupport;
> import org.apache.tapestry5.annotations.AfterRender;
> import org.apache.tapestry5.annotations.Property;
> import org.apache.tapestry5.ioc.annotations.Inject;
>
> import com.mundor.internet.interfazweb.model.medicion.Medicion;
> import com.mundor.internet.interfazweb.model.statisticservice.MedicionBlock;
> import 
> com.mundor.internet.interfazweb.model.statisticservice.StatisticService;
> import 
> com.mundor.internet.interfazweb.modelutil.exceptions.InstanceNotFoundException;
>
> public class ShowMediciones {
>
>  private final static int MEASUREMENTS_PER_PAGE = 10;
>
>  private int startIndex = 0;
>  private Long idVariable;
>  private MedicionBlock medicionBlock;
>
> �...@suppresswarnings("unused")
> �...@property
>  private Medicion medicion;
>
> �...@inject
>  private StatisticService statisticService;
>
> �...@inject
>  private Locale locale;
>
> �...@inject
>    private RenderSupport renderSupport;
>
>   �...@afterrender
>    public void afterRender() {
>
>            renderSupport.addScript(
>
>                 " var d1 = [];" +
>                 " for (var i = 0; i < 14; i += 0.5)"+
>                     "d1.push([i, Math.sin(i)]);"+
>
>                  "var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];"+
>
>
>                  "var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];"+
>
>                  "$.plot($(\"#placeholder\"), [ d1, d2, d3 ]);"
>
>
>
>
>            );
>    }
>
>  public List getMediciones() {
>
>  return medicionBlock.getMediciones();
>
>  }
>
>
>  public DateFormat getDateFormat() {
>  return 
> DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,locale);
>
>  }
>
>  public Object[] getPreviousLinkContext() {
>
>  if (startIndex - MEASUREMENTS_PER_PAGE >= 0) {
>   return new Object[] { idVariable,
>     startIndex - MEASUREMENTS_PER_PAGE };
>  } else {
>   return null;
>  }
>
>  }
>
>  public Object[] getNextLinkContext() {
>
>  if (medicionBlock.getExistMoreMeasurements()) {
>   return new Object[] { idVariable,
>     startIndex + MEASUREMENTS_PER_PAGE };
>  } else {
>   return null;
>  }
>
>  }
>
>  Object[] onPassivate() {
>  return new Object[] { idVariable, startIndex };
>  }
>
>
>  void onActivate(Long idVariable, int startIndex)
>   throws InstanceNotFoundException {
>
>  this.idVariable = idVariable;
>  this.startIndex = startIndex;
>
>     medicionBlock = statisticService.obtenerMedicionesPorVariable(idVariable, 
> startIndex, MEASUREMENTS_PER_PAGE);
>
>  }
>
>
> }
>
> _
>
> page ShowMediciones.tml:
>
> _
>
> http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";
>
> t:type="Layout" t:pageTitle="${message:title}" 
> t:menuExplanation="menuExplanation">
>
>
> 
>
>
> ${message:noMediciones}.
>
>
> 
>
>
> 
>
>
> 
>
>
>
> 
>
>
> 
>
> ${message:medicionId-label}
>
> 
>
> ${medicion.idMedicion}
>
> 
>
>
> 
>
>
> 
>
> ${message:medicionValor-label}
>
> 
>
> ${medicion.valor}
>
> 
>
>
> 
>
>
> 
>
> ${message:medicionFecha-label}
>
> 
>
> 
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
> t:context="previousLinkContext">
>
> ${message:link-previous}
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
> t:context="nextLinkContext">
>
> ${message:link-next}
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
> 
>
>
>
> 
>
>
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-29 Thread Ignacio González Arboleya
This is what I have:

class "ShowMediciones.java":
_
package com.mundor.internet.interfazweb.web.pages.monitorizacion;


import java.text.DateFormat;
import java.util.List;
import java.util.Locale;

import org.apache.tapestry5.RenderSupport;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.mundor.internet.interfazweb.model.medicion.Medicion;
import com.mundor.internet.interfazweb.model.statisticservice.MedicionBlock;
import com.mundor.internet.interfazweb.model.statisticservice.StatisticService;
import 
com.mundor.internet.interfazweb.modelutil.exceptions.InstanceNotFoundException;

public class ShowMediciones {
 
 private final static int MEASUREMENTS_PER_PAGE = 10;
 
 private int startIndex = 0;
 private Long idVariable;
 private MedicionBlock medicionBlock;
 
 @SuppressWarnings("unused")
 @Property
 private Medicion medicion;
 
 @Inject
 private StatisticService statisticService;
 
 @Inject
 private Locale locale;

 @Inject
private RenderSupport renderSupport;
 
@AfterRender
public void afterRender() {
 
renderSupport.addScript(

 " var d1 = [];" +
 " for (var i = 0; i < 14; i += 0.5)"+
 "d1.push([i, Math.sin(i)]);"+

  "var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];"+


  "var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];"+
  
  "$.plot($(\"#placeholder\"), [ d1, d2, d3 ]);"




);
}
 
 public List getMediciones() {

  return medicionBlock.getMediciones();
  
 }
 
 
 public DateFormat getDateFormat() {
  return 
DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,locale);

 }
 
 public Object[] getPreviousLinkContext() {

  if (startIndex - MEASUREMENTS_PER_PAGE >= 0) {
   return new Object[] { idVariable,
 startIndex - MEASUREMENTS_PER_PAGE };
  } else {
   return null;
  }

 }

 public Object[] getNextLinkContext() {

  if (medicionBlock.getExistMoreMeasurements()) {
   return new Object[] { idVariable,
 startIndex + MEASUREMENTS_PER_PAGE };
  } else {
   return null;
  }

 }

 Object[] onPassivate() {
  return new Object[] { idVariable, startIndex };
 }


 void onActivate(Long idVariable, int startIndex)
   throws InstanceNotFoundException {
  
  this.idVariable = idVariable;
  this.startIndex = startIndex;

 medicionBlock = statisticService.obtenerMedicionesPorVariable(idVariable, 
startIndex, MEASUREMENTS_PER_PAGE);

 }


}

_

page ShowMediciones.tml:

_

http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";

t:type="Layout" t:pageTitle="${message:title}" 
t:menuExplanation="menuExplanation">





${message:noMediciones}.

















${message:medicionId-label} 

 

${medicion.idMedicion}




 




${message:medicionValor-label} 

 

${medicion.valor}




 




${message:medicionFecha-label} 

 






 



















${message:link-previous}


















${message:link-next}

























Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-29 Thread Juan E. Maya
The line inside the Tapestry.onDOMLoaded function must be the one that
is causing the problem. are u sure u aren't adding that line?

2009/7/29 Ignacio González Arboleya :
> Hi,
>
>   I have no erros, it's just that the chart that should be loaded it isn't. 
> However, if I delete those 2 lines, it is load perfectly...

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-29 Thread Ignacio González Arboleya
Hi,

   I have no erros, it's just that the chart that should be loaded it isn't. 
However, if I delete those 2 lines, it is load perfectly...

Re: Problem with Tapestry.onDOMLoaded when generating java script

2009-07-29 Thread Juan E. Maya
Hi Ignacio, what kind of problem are u having? do u get an specific
error? have u tried to use firebug to debug the javascript and fine
the problem?
I am pretty confident the problem is with the javascript u have
written and not Tapestry's


2009/7/29 Ignacio González Arboleya :
> Hi everybody,
>
>        a few days ago I wrote this message: 
> http://markmail.org/thread/dw56hbrdimi7rcta
>
>        Finally, thanked to the people who answered my question, I decided to 
> use RenderSupport.addScript()
>        to generate javascript dinamically.
>
>        But, now, I am having problems since the javascript code generated is 
> like this:
>
> Tapestry.DEBUG_ENABLED = true;
> Tapestry.onDOMLoaded(function() {
>  var d1 = []; for (var i = 0; i < 14; i += 0.5)d1.push([i, Math.sin(i)]);var 
> d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];var d3 = [[0, 12], [7, 12], null, [7, 
> 2.5], [12, 2.5]];$.plot($("#placeholder"), [ d1, d2, d3 ]);
> });
>       The code is correct, but my web browsers do not process it because of 
> these two lines:        Tapestry.DEBUG_ENABLED = true;
>        Tapestry.onDOMLoaded(function() {
>        I am sure that these two lines are the problem, since I have already 
> tried deleting them and everything works fine.Could anyone help me please? 
> What can I do to make my browsers recognize those 2 lines? Thankyou, Nacho.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org