I have an api controller which generates response as xml and need to pass this xml to an external angularjs application and parse this to show result.
I have tried this so far.
/PaymentSuccess.html?response=<xml>....<xml>
I dont think this is the best way of doing because the uri seems lengthy and ugly.
Is there any better way so that i can pass the xml to the uri and read that from the angular application.
Related
Is there any way to get CRX content without using OSGI service?
Am looking for an use case to implement a top navigation for a website which is required to read page names and its properties via javascript framework like angular JS.
You could get it as JSON or XML, make a server call to path with extension XML or JSON. JSON allows you depth based selectors to go down the tree hierarchy not sure if its same with XML.
/my/page/path.xml or /my/page/path.<depth>.json, you can get the hostname and port details from the request URI to make the complete URL for the data call.
I would suggest you use the following JSON API's provided by sling to accomplish your task of getting page names and its properties.
Firstly to crawl all the pages under a given path, you need to use the .pages.json selector. For example to get all child pages of /content/company/en_US, perform a JSON GET on
HTTP GET <Host>/content/company/en_US.pages.json
Next for each path returned by the above GET call, you need to grab the _jcr_content.json of the page
(E.g.)
HTTP GET <Host>/content/company/en_US/home/_jcr_content.json
The above JSON call should provide you all the page properties of this particular page.
Please Note: The above method is generic and can be applied to any JCR Path hosted in Sling/AEM. Also typically you cannot get this level of JCR access in a publisher environment due to security rules that might prevent JCR crawling. Hope this helps
Is it viable to consume XML Response from a Webservice by posting xml using angular JS. Any suggestions would be helpfull.
One option can be just convert the xml object to the json object
https://code.google.com/p/jquery-xml2json-plugin/
i had been working in a Spring Rest Data API in an application (just for fun).
I have the core made, works fine but now I want to use AngularJS as front-end.
I had work with Jackson (Mapping Java Objects to JSON), but with Spring Rest Data the Json response it's diferent, it has _embedded, _links, self, etc. links that make me confuse. I have something like this in the root url http://localhost/8080/app/api/tarifas
I have used a JS script called restangular but i have serveral problems (I'm newbie with Angular)
In my controller i have this
Check the error
If I add a RestangularProvider in my app.config(...) and change the Controller to getList instead get, works fine, but I need several entities data formats.
Any help it's welcome. If you know a better way please tell me.
Thanks!!
UPDATE
I found a form to do this (i donĀ“t know if it's the better) but now my problem is the next:
I have objects that has other objects as attributes (realtionship), and the reference in the JSON is a link (not an object). Then, in the grid; the value of the description's internal object is blank. To get the json data I found this
Now I have the next content for one register (one of the grid)
And my grid (In Angular, HTML) looks like this (empty fields)
How can I retrieve the attribute description from the member estado, categoria, etc. and show it in the grid. Should make the request to get it?
Thanks!!
You can use either angular.toJson or json.stringify
Angular-toJson documentation
Json.stringify documentation
I'm new to AngularJS and client side stuff and I'm adding a new page to an old application that uses Struts 1.3 as its framework. I would like to use AngularJS for the front end.
I know how to return JSON from the action class by writing the JSON to the front end and returning null for the action forward. However, I'm unclear how I would populate the scope variables within the controller after the GET. If I use a GET in the controller and get JSON back, how does my ActionForm fit into all this? Is it useful at all? Can I have a GET and POST for the same controller if I want to send new values back to my action? And, can I have variables like:
$scope.items={}
$scope.items.name=""
$scope.items.email=""
And then just send json.stringify(items) as my data in the POST if I can't use the form somehow?
I haven't found much information using AngularJS with Struts 1.3 so far.
EDIT:
I'll try to answer as best as possible what conclusion I came to but my questions above were very vague since I didn't really know what I was talking about and my position with the company I worked for has ended so I no longer have access to that code. What I meant to ask earlier was what am I going to do with the action form that I usually use for Struts actions and how am I going to get data from the front end to my action class during a POST. I found out that my usual ActionfForm was useless for what I wanted to do so I got rid of it and wrote a JSON object during the GET that would be modified on the frontend and passed back to another action when I did the POST. This is done like a normal POST to whateverAction.do, but I had to configure the data I was sending in the POST and name it something. I then picked up the modified JSON object by using
request.getParameter("jsonObjName")
and parsed it to different LinkedHashMap objects for each object in the JSON object. I think you can use the JSONObject classes instead of LinkedHashMap to parse if you are using JavaEE but I was using SE so I didn't have access to those in this project. Here a link to another page I used for the POST configurations:
How to get the data in Struts from AngularJS post
On the Java side you can also try to use Gson library that allows you to parse string to and from JSON, but Struts 1 generally won't fit well with AngularJS, if you remove the form on Java side, than makes no sense to keep Struts 1.
And if no possibility to remove Struts 1, than just keep Struts 1 for existing functionality and start using Struts 2 for new screens where AngularJS is applied.
It will be much easier cause the JSON from AngularJS' POST will automatically be bound to the bean object that has to match to JSON properties format and name.
All of the examples of the ng-grid (AngularUi grid component) use GET requests.
I am using CakePhp and have got an Action function in a controller which returns json.
Is there a way to secure GET requests to that Action function? Do I use the in-built security of CakePhp to restrict access to that controller?
At the moment, I can just load the route to it in a browser for the world to see. And that is not ideal.
This is what I am looking for - SecurityComponent::$csrfCheck
Found at the security component part of the API.
I should have looked harder.
Thanks!