Thanks for the suggestion. Not exactly as I think the problem is more
with building a datatable using the DataSourceServlet and properly
passing that pack to the JSP page but I will definitely look into
controlling the view through JavaScript functions.


On Aug 4, 9:35 am, Yuval Ronen <[email protected]> wrote:
> If you want that clicking a button will show a visualization, then the
> onclick of the button should call query.send(handleQueryResponse), and start
> rolling the visualization. Is this what you mean?
>
> On Wed, Aug 4, 2010 at 6:17 AM, beejon <[email protected]> wrote:
> > Hello... I have a basic Visualizations project comprised of a JSP and
> > servlet.  The JSP is an HTML form allowing the user to query a DB and
> > build a datatable and annotated time with input variables. Everything
> > works fine if the JSP is requested (by browser). The JavaScript will
> > call the DispatcherServlet and the visualization is displayed as
> > expected.  However, if the user makes a GET request by submitting the
> > <form action="/DispatcherServlet" method="get"> it calls the servlet
> > and only the JSON is returned to the browser.
>
> > I am not correctly understanding how to manage the interaction of the
> > controller servlet getting / sending the datatable and javascript
> > instantiating an instance to get the datatable. I have tried adding
> > the datatable to the response and using the RequestDispatcher forward
> > method() but cannot figure it out.
>
> > I appreciate any help or suggestions. Thanks.
>
> > DispatcherServlet.java
> > ************************************************
>
> > public class DispatcherServlet extends DataSourceServlet {
> >       �...@override
> >        protected void doGet(HttpServletRequest req, HttpServletResponse
> > resp) throws IOException {
> >        DataSourceRequest dsRequest = null;
>
> >        try {
>
> >                dsRequest = new DataSourceRequest(req);
>
> >                QueryPair query =
> > DataSourceHelper.splitQuery(dsRequest.getQuery(),
> > Capabilities.SELECT);
>
> >                DataTable data =
> > generateDataTable(query.getDataSourceQuery(), req);
>
> >                DataTable newData =
> > DataSourceHelper.applyQuery(query.getCompletionQuery(), data,
> >                 dsRequest.getUserLocale());
>
> >                DataSourceHelper.setServletResponse(newData, dsRequest,
> > resp);
>
> >        } catch (Exception e) { System.out.println(e); }
>
> >        }
>
> >       �...@override
> >        public DataTable generateDataTable(Query query, HttpServletRequest
> > req) {
>
> >                DataTable data = new DataTable();
> >                // MySQL query ... build data table
> >                // req.getParameter("") is used to build the query
> >                return data;
>
> >        }
> > }
>
> > index.jsp ************************************************
>
> >  google.load('visualization', '1', {'packages': ['table',
> > 'annotatedtimeline']});
> >  google.setOnLoadCallback(init);
> >  function init() {
> >        var query = new google.visualization.Query('DispatcherServlet');
> >    query.send(handleQueryResponse);
> >  }
>
> >  function handleQueryResponse(response) {
> >        if (response.isError()) {
> >      alert('Error in query: ' + response.getMessage() + ' ' +
> > response.getDetailedMessage());
> >      return;
> >    }
> >        var data = response.getDataTable();
> >    var table = new
> > google.visualization.Table(document.getElementById('table_div'));
> >    table.draw(data);
> >  }
>
> >  <form action="DispatcherServlet" method="get"
> > name="object_select">  ... </form>
> >  <div id="table_div" style="width: 800px;height:300px;"></div>
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Visualization API" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-visualization-api%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-visualization-api?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to