Laura,
Instead of
tl.loadJSON(json_events, document.location.href);
try
eventSource.loadJSON(json_events, document.location.href);
David
Laura Vogt-Schilb wrote:
> Thanks for your answers!
>
> My problem is that I need to make two things at the same time :
> formatting data for the events and finding the values to configure my
> timeline (central date and interval units and pixels).
> I was able to use the servlet solution, but it makes me duplicate my
> logic. I would like to make all the logic before printing my jsp, that
> is why I would like to be able to retrieve the events directly from
> the jsp.
>
> I am sorry I cannot give you an url where you can see my timeline, but
> the one I am using is very basic, I give you my source attached.
>
> Thanks in advance,
> Laura
>
>
>
> -----Mensaje original-----
> *De:* [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] nombre de *Graham Forte
> *Enviado el:* jueves, 12 de abril de 2007 16:17
> *Para:* General List
> *Asunto:* Re: loading events from a json object included in the
> same jsp
>
> You could just dump that json into a servlet as a String.
>
>
> YourServlet:
>
> <%
> PrintWriter out = new PrintWriter();
> String theJSON = " 'events' : [{'start': '1924','title':
> 'Barfusserkirche','description': 'by Lyonel Feininger,
> American/German Painter,1871-1956',"+
> "'image':
>
> 'http://images.allposters.com/images/AWI/NR096_b.jpg','link':'http://www.allposters.com/-sp/Barfusserkirche-1924-Posters_i1116895_.htm'},
>
> <http://images.allposters.com/images/AWI/NR096_b.jpg%27,%27link%27:%27http://www.allposters.com/-sp/Barfusserkirche-1924-Posters_i1116895_.htm%27%7D,>"+
> "{'start': '1913','end': '1929','title': 'Three
> Figures','description': 'by Kasimir Malevich, Ukrainian
> Painter,1878-1935',"+
> "'image':
>
> 'http://images.allposters.com/images/BRGPOD/75857_b.jpg','link':'http://www.allposters.com/-sp/Three-Figures-1913-28-Posters_i1349989_.htm'},]};
>
> <http://images.allposters.com/images/BRGPOD/75857_b.jpg%27,%27link%27:%27http://www.allposters.com/-sp/Three-Figures-1913-28-Posters_i1349989_.htm%27%7D,%5D%7D;>";
> out.println(theJSON);
>
> %>
>
> And then in your jsp you can do the following:
>
> tl = Timeline.create(document.getElementById("my-timeline"),
> bandInfos);
> tl.loadJSON("urlOfYourServlet", function(json, url) {
> eventSource.loadJSON(json, url); });
>
> HTH.
>
> On 4/12/07, *Laura Vogt-Schilb* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Hi David,
>
> Thanks for your answer. I tried waht you suggested but I get
> the exception :
> "Syntax Error: missing } in XML expression"
>
> Do you know where it can be from?
>
> Thanks in advance,
> Laura
>
> -----Mensaje original-----
> De: [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> [mailto:[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>]En nombre de David Huynh
> Enviado el: jueves, 12 de abril de 2007 15:19
> Para: General List
> Asunto: Re: loading events from a json object included in the
> same jsp
>
>
> Hi Laura,
>
> Instead of
> tl.loadJSON(json_events, function(json, url) {
> eventSource.loadJSON(json, url);
> });
> }
>
> have you tried this?
> eventSource.loadJSON(json_events, document.location.href);
>
> David
>
>
> Laura Vogt-Schilb wrote:
> > Hi everybody!
> >
> > Do you know if there is any function that allows me to load
> the events
> > source as json, directly from the same jsp where I have my
> timeline
> > script? I would like to have something like this :
> >
> >
> > var json_events={
> > 'dateTimeFormat': 'iso8601',
> > 'wikiURL': "http://simile.mit.edu/shelf/",
> > 'wikiSection': "Simile Cubism Timeline",
> >
> > 'events' : [
> > {'start': '1924',
> > 'title': 'Barfusserkirche',
> > 'description': 'by Lyonel Feininger, American/German
> Painter,
> > 1871-1956',
> > 'image': '
> http://images.allposters.com/images/AWI/NR096_b.jpg',
> > 'link':
> >
>
> 'http://www.allposters.com/-sp/Barfusserkirche-1924-Posters_i1116895_.htm
>
> <http://www.allposters.com/-sp/Barfusserkirche-1924-Posters_i1116895_.htm>'
> > },
> >
> >
> > {'start': '1913',
> > 'end': '1929',
> > 'title': 'Three Figures',
> > 'description': 'by Kasimir Malevich, Ukrainian Painter,
> > 1878-1935',
> > 'image':
> 'http://images.allposters.com/images/BRGPOD/75857_b.jpg',
> > 'link':
> >
>
> 'http://www.allposters.com/-sp/Three-Figures-1913-28-Posters_i1349989_.htm'
> > },
> >
> > ]};
> >
> > var tl;
> > function onLoad() {
> > var eventSource = new
> Timeline.DefaultEventSource(0);
> >
> > var theme = Timeline.ClassicTheme.create();
> > theme.event.bubble.width = 320;
> > theme.event.bubble.height = 220;
> > var d =
> Timeline.DateTime.parseGregorianDateTime("1900")
> > var bandInfos = [
> > Timeline.createBandInfo({
> > width: "100%",
> > intervalUnit: Timeline.DateTime.DECADE,
> > intervalPixels: 200,
> > eventSource: eventSource,
> > date: d,
> > theme: theme
> > })
> > ];
> >
> > tl =
> > Timeline.create(document.getElementById ("lauretta-timeline"),
> > bandInfos, Timeline.HORIZONTAL);
> >
> > // -> Here I would like to use something like this :
> > tl.loadJSON(json_events, function(json, url) {
> > eventSource.loadJSON(json, url);
> > });
> > }
> >
> > var resizeTimerID = null;
> > function onResize() {
> > if (resizeTimerID == null) {
> > resizeTimerID = window.setTimeout(function() {
> > resizeTimerID = null;
> > tl.layout();
> > }, 500);
> > }
> > }
> >
> > I have been looking at the sources and found in bundle.js a
> loadJSON
> > function, but I don't know how to change it for it to do
> what I would
> > like.
> >
> > Thanks in adavance for your help!
> >
> > Best regards
> > Laura
> > **
> >
>
> ------------------------------------------------------------------------
> >
> > _______________________________________________
> > General mailing list
> > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > http://simile.mit.edu/mailman/listinfo/general
> >
>
> _______________________________________________
> General mailing list
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> http://simile.mit.edu/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> http://simile.mit.edu/mailman/listinfo/general
>
>
>
> ------------------------------------------------------------------------
>
> Linea del tiempo de lauretta
> ------------------------------------------------------------------------
>
> _______________________________________________
> General mailing list
> [EMAIL PROTECTED]
> http://simile.mit.edu/mailman/listinfo/general
>
_______________________________________________
General mailing list
[EMAIL PROTECTED]
http://simile.mit.edu/mailman/listinfo/general