Dojo Restful server access - rest

How to implement restful access from Dojo client to java server running in tomcat?
I need to make restful request to server and get data (json or xml format) and update the grid. How to do it?
I read the following posts, but i couldn't understand anything.
http://www.sitepen.com/blog/2008/06/13/restful-json-dojo-data/
http://www.sitepen.com/blog/2008/11/21/effective-use-of-jsonreststore-referencing-lazy-loading-and-more/
Can anyone give me complete source code and the explanation ?
Since I am new to Dojo I feel hard to do this. I don't want web services to be included.

For the REST part, you can use the Wizard of Netbeans (the tutorial is on Glassfish, but I don't see any reason why this should not work on Tomcat as well). See here the tutorial:
http://netbeans.org/kb/docs/websvc/rest.html .
For the dojo part, I have posted a complete example (which integrates perfectly with the REST implementation provided by Netbeans) here:
Dojo grid nested json
EDITED
In the Netbeans' tutorial there is a link for Tomcat users.

Related

GWT and Websphere Commerce?

In one of our projects we have reached the point where we have to ditch out old Madisson-based platform and move on. Unfortunately, Aurora does not look like a perfect fit, so we are looking at alternatives.
One option is to build a GWT based front end. This would allow us to drop JSP, Dojo and most JavaScript in favor of a Java-based platform.
Has anybody tried anything like this before?
How would I make it work with for example Dynacache?
I would read this redbook. It has an example of how to code the JSPs - http://www.redbooks.ibm.com/redbooks/pdfs/sg247393.pdf.
Also if you're moving to FEP6, you'll also want to use the WebSphere Commerce tag libraries and some of the metatags so that the inline editing and some of the advanced store preview features work correctly.
Finally, I would engage your local IBM technical team since there are other customer who have done this before and you want to learn from their best practices.
I've no experience with IBM starter stores. I'll try to help, though.
The back-end/front-end integration occurs by putting RPC servlets in a package shared by your back-end and front-end code, as explained here. It shouldn't be a problem to set that up.
I've no idea if dynamic caching will still work, but those RPC calls are also based on URL and I don't see why the cache wouldn't work for them if you set that up properly.
If you don't want to rewrite all your client from scratch and for a step-by-step migration, you could keep your JSP and use little GWT modules to replace the Dojo/js code on your pages.
In the same way your old Dojo/js code can be called from the GWT module if you would like to keep some parts of it.
Hope it helps...
I am not gonna ask you why you want to drop Madison starter store JSPs/DOJO apis and javascript, But that will be massive amount of work for you !
I guess you need to architect your calling from GWT to Server side to be like RESTfull format and can take parameters and add the dynacache entries like servlet/Rest paths that way you can cache the responses from back end which can be JSON or XML format . and of-course that will work
e.g:
<cache-entry>
<class>servlet</class>
<name>/path/GetCatalogs</name>
<property
name="save-attributes">false</property>
<property name="store-cookies">false</property>
<timeout>3600</timeout>
<priority>3</priority>
<cache-id>
<component id="storeId" type="parameter">
<required>true</required>
</component>
<component id="catalogId" type="parameter">
<required>true</required>
</component>
</cache-id>
...
</cache-entry>

Cannot find HTML resource for file in RESTful project

I have been trying to implement a RESTful web service by following the tutorial here.
I have been searching online for the issue I am encountering but without any help. When implementing the CRUD web service, the article includes an HTML file. I have tried putting it both in WebContent and in WebContent/WEB-INF, but I cannot get it to work. I have also tried applying the solutions listed here, but the HTML file still didn't work.
The other functions do work, it's just this that I am having a problem with. I tried using:
localhost:8080/de.vogella.jersey.todo/rest/create_todo.html
localhost:8080/de.vogella.jersey.todo/create_todo.html
localhost:8080/de.vogella.jersey.todo/WEB-INF/create_todo.html
The error I am getting is from Tomcat not finding the resource.
Nothing works and I would really appreciate any help I can get. :)

Including facebook.php in tomcat + liferay

I want to make a site for me in which I can use the facebook api features.
I got a tomcat webserver ans liferay is installed on it.
Now I need to implement the facebook.php to this but I don't know where to put it.
I wrote some code in php to get for example my id or to post into my own profile. But liferay oder tomcat couldn't load the things from facebook.php so the server doesn't know the methods and can't do what I want him to do.
Can anybody tell me how to solve this problem?
I've never actually done it before because I've tried to keep PHP code off Liferay and used other methods to access 3rd APIs. However the Tomcat wiki has a post on it:
Installing PHP on Tomcat
Or what maybe a better option is you use the Facebook JavaScript API and you create a new Liferay portlet which uses this API instead of using PHP.
How can I use Facebook JAVA API in my application? will help you find the java api for facebook. With regards to getting started with programming: That one is far beyond what can be answered here. But basically: Try to access the API in the language that you're working in. Don't bridge to a different language in order to bridge then to an external system.
There are a lot more hits when you google for facebook java api in case that link doesn't help.

Web based plugin architecture for simple user interfaces

I have a web based application using Primefaces with a very basic plug-in like architecture. The configuration of these plug-ins was all handled with xml, which is not so user friendly system.
I would now like to allow for each plug-in to be configurable via the web application, what are my options?
I have looked into Portals and Portlets but that seems like a rather big change to my application and my plug-ins do not require such complex user interfaces, a textbox or two of configuration is more than enough.
Does anyone have any suggestions or advice and what would be the best route here?
Create a simple page , per plugin that read the XML file, parse the option that you want to change , present it to the user with a simple interface, and save back the XML file.
Take care of the saving part and password-protect this page!

Dynamically generated GET request to an external database

I'm asking for help to my problem. I am new to JSF and I have a simple JSF online store demo page. I don't even use navigation rules since I only include the page with search results beneath the searching tags fields. The problem is a have sth like 15 fields (input texts and menus) to perform a detailed search. After selecting the fields and clicking on the search button I have to generate a long GET request for the database (which is located on a different server than my page and uses REST), receive the response (xml format), extract the search results and publish them on the page. The search patter is sth like this:
http://serveradress/search/ [x1][x2][x3]....[xn]
Where x1-xn are the values for the search engine and have to be read from the page's fields, so it has to be generated dynamically. The get request can be very long since there are 15 fields and one can have some additional options. The data base is on a different server and responds with an xml script with search results.
I found some solutions on the internet on how to perform a GET request using params but don't really know how can it fit to my problem since I have to receive the results from an external data base and manage them rather inside the java bean for publishing (i do not want to change the url adres of my page).
I am using JSF 1.2, with Eclipse IDE and JBoss on Ubuntu. The search request has to be GET since the data base uses that REST interface.
I am asking for your help in this matter if someone is able to find a solution to this problem or provide me with some link. I would strongly appreciate an example code with the solution.
Use JBOSS resteasy RESTful API's