You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com> on 2009/11/19 16:53:51 UTC

JSON + Ajax + toolbox

Hi, 

I have a question. I loaded portlet information from ajax to do the
solution I'm on charge of.

Where can I get schema from the ajax response Get Portlets...

To use it here:


                var dataIn = Y.DataType.XML.parse(data),
    		schema = {  resultListLocator: "status", resultFields:
[{key:"status"}] },
    		dataOut = Y.DataSchema.XML.apply(schema, dataIn);


I need to add portlets array and portletInfo definition. 

Should we put object schemas in a place accesible to everyone? Should
they be shared objects?
Should we have a shared library for this pojos?

Thank you.

Re: JSON + Ajax + toolbox

Posted by David Sean Taylor <d....@onehippo.com>.
On Nov 19, 2009, at 8:36 AM, Gonzalo Aguilar Delgado wrote:

> Hi  David,
>
> I've already done the interface. I got results and everything is
> working.
>

Great!

> The problem as you say is about working with xml... It's a pain. I  
> can't
> make it work
> with xml. And already did a small patch because getportlets action  
> has a
> bug that already
> corrected.  I will send you the patches when finished.

Agreed (xml is a pain on the client side in comparison with json, and  
its slower). I would be fine with making json the default format for  
all apis.

>
> What I will do now is to add the json interface to the action and  
> give a
> try with json.
>
> It's my first time using YUI3 so I'm going a little bit slow. But I
> think I got it.

Don' t worry. Take your time and learn, no rush. More important that  
you become knowledgeable and enjoy coding



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: JSON + Ajax + toolbox

Posted by David Sean Taylor <d....@onehippo.com>.

On Nov 19, 2009, at 8:36 AM, Gonzalo Aguilar Delgado wrote:

> Hi  David,
>
> I've already done the interface. I got results and everything is
> working.
>
> The problem as you say is about working with xml... It's a pain. I  
> can't
> make it work
> with xml.

Regarding XML, here is an example Im working on for move absolute  
action:

   var onMoveComplete = function(id, o, args) {
     	var id = id; // Transaction ID.
     	var data = o.responseText; // Response data.
     	Y.log("move result = " + data);
     	var dataIn = Y.DataType.XML.parse(data),    	 	
     	schema = {
     		metaFields: {status:"//status", action:"//action", reason:"// 
reason", id:"//id",
     	      oldcol: "//old_position/col", oldrow: "//old_position/row",
     	      newcol: "//new_position/col", newrow: "//new_position/row"}
     	 },
     	dataOut = Y.DataSchema.XML.apply(schema, dataIn);
	Y.log("status = " + dataOut.meta.status);
	Y.log("action = " + dataOut.meta.action);
	Y.log("reason = " + dataOut.meta.reason);
	Y.log("id = " + dataOut.meta.id);
	Y.log("oldcol = " + dataOut.meta.oldcol);
	Y.log("oldrow = " + dataOut.meta.oldrow);
	Y.log("newcol = " + dataOut.meta.newcol);
	Y.log("newcol = " + dataOut.meta.newrow);

	var widgetId = args[0];
     };



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: JSON + Ajax + toolbox

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Hi  David, 

I've already done the interface. I got results and everything is
working.

The problem as you say is about working with xml... It's a pain. I can't
make it work
with xml. And already did a small patch because getportlets action has a
bug that already
corrected.  I will send you the patches when finished.

What I will do now is to add the json interface to the action and give a
try with json. 

It's my first time using YUI3 so I'm going a little bit slow. But I
think I got it.

Thank you for pointing me to the right directions. 

NOTE: I will also add a small library of json definitions that I will
complete step by step.

Tnx



> 
> http://localhost:8080/jetspeed/ajaxapi?action=getportlets
> Take a look at GetPortletsAction.java. There is request parameter  
> "format" which can be either "json" or "xml". Not all of the actions  
> support json. I would like to support json in all actions with the  
> next release. The getportlets action for instance, only supports xml.  
> See getportlets.vm for details. See getthemes.vm for a json example.  
> If you dont want to work on the server side apis, let me know. I could  
> quickly write the json vm script for you.....
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> 

Re: JSON + Ajax + toolbox

Posted by David Sean Taylor <d....@onehippo.com>.
On Nov 19, 2009, at 7:53 AM, Gonzalo Aguilar Delgado wrote:

> Hi,
>
> I have a question. I loaded portlet information from ajax to do the
> solution I'm on charge of.
>
> Where can I get schema from the ajax response Get Portlets...
>
> To use it here:
>
>
>                var dataIn = Y.DataType.XML.parse(data),
>    		schema = {  resultListLocator: "status", resultFields:
> [{key:"status"}] },
>    		dataOut = Y.DataSchema.XML.apply(schema, dataIn);
>
>
> I need to add portlets array and portletInfo definition.
>
> Should we put object schemas in a place accesible to everyone? Should
> they be shared objects?
> Should we have a shared library for this pojos?
>

Try this from your browser:

http://localhost:8080/jetspeed/ajaxapi?action=getportlets
Take a look at GetPortletsAction.java. There is request parameter  
"format" which can be either "json" or "xml". Not all of the actions  
support json. I would like to support json in all actions with the  
next release. The getportlets action for instance, only supports xml.  
See getportlets.vm for details. See getthemes.vm for a json example.  
If you dont want to work on the server side apis, let me know. I could  
quickly write the json vm script for you.....

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: JSON + Ajax + toolbox

Posted by David Sean Taylor <d....@onehippo.com>.
dtaylor@onehippo.com  www.onehippo.com
San Francisco - Hippo USA Inc. 185 H Street, Suite B Petaluma CA 94952  
+1 (707) 773-4646
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466






On Nov 19, 2009, at 7:53 AM, Gonzalo Aguilar Delgado wrote:

> Hi,
>
> I have a question. I loaded portlet information from ajax to do the
> solution I'm on charge of.
>
> Where can I get schema from the ajax response Get Portlets...
>
> To use it here:
>
>
>                var dataIn = Y.DataType.XML.parse(data),
>    		schema = {  resultListLocator: "status", resultFields:
> [{key:"status"}] },
>    		dataOut = Y.DataSchema.XML.apply(schema, dataIn);
>

>
> I need to add portlets array and portletInfo definition.
>
> Should we put object schemas in a place accesible to everyone? Should
> they be shared objects?

there are currently no xsds for these apis, but feel free to  
contribute one if you think they are required. I think its easier to  
work with json data though from javascript

> Should we have a shared library for this pojos?
>
> Thank you.

Also , for retrieving portlets, here is an example script you can use:

     	var uri = document.location.href;
     	uri = uri.replace("/ui", "/ajaxapi");
     	var uri = uri + "?action=getportlets";
         Y.on('io:complete', onGetPortletsComplete, this, [windowId]);

I hope to commit error handling code (parsing the response and  
checking the response code) this morning


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org