Parameter Passing from ExtJs to Html - html

I am trying to pass an Extjs parameter ,which I retrieved from a store in the code, to html code.
Any ideas?

ok.so here is the structure.
I am trying to make an ajax call with updater.update from jsp.
The call goes to controller and returns a jsp which includes another jsp(jsp include is used)
the jsp ,which is included by the other one, needs an attribute which is on a store object. So I need to fetch it from the store and place it on the html side.
Is it more clear now?
Thanks for your replies
PS: Actually my real problem is: the jsp ,which is included by the other jsp, includes scripts and as I have read from the responses on internet, to call a jsp page(which includes javascripts) through ajax and try to render it, is not possible on ie7 and ie 8(the famous "Could not complete the operation due to error 80020101" error ). Is it correct?

Related

JSON object losing info between API call and Frontend

I'm making a website that gets its info from a RESTapi I've written and hosted myself, have had no data problems thus far.
Now I'm trying a simple retrieve of a json object and I get all the info correctly as shown here in the API. (Visualized & tested in Swagger)
As you can clearly see, it retrieves it the complete object and underlying objects correctly (blurred sensitive info).
Pay attention to the property "AmountOfEggs" though.
Now when i call this api endpoint (exactly the same way) in my site and console.log the result.data, this is the feedback.
Now for some reason I can't recieve AmountOfEggs in my frontend.
I've recreated the entire object, wrote different names, passed different props (Id, NumberBus, etc are passed in this situation with no problem, which are also int (number) types).
I have no idea why this property gets "dropped" in the transfer and filled with/defaults to an empty string.
Any help would be greatly appreciated.
I found where it went wrong and it's due to different factors.
To start, I am making this site using the Vue framework, which has reactive components, which means, data gets adjusted and you get live updated components on your views/pages.
In the page that contained the call, I also wanted to add dynamic styling. The code I used for this is the following:
v-for="seller in retrievedSellers"
:key="seller.Id"
:class="[
'sellerStyle'
, (seller.AmountOfEggs = 0 ? 'grey-out-seller' : ''),
]"
Now two things to note, first of all this might look like backend coding but this is Vue logic on the .vue file which handles the dynamic options that Vue provides so I never thought to look here for the error.
The error of couse is the 'seller.AmountOfEggs = 0' part, using one equal sign (assignment) instead of two (comparison).
So I learned,
Vue doesn't throw errors on assignments in code that is used to generate frontend (where you should NEVER alter your data).
My console.log was the moment the response of the API came in, where apparently it was already assigned a new value (due to my code above) before hitting the console.log.
It still greatly surprises me that Vue handles ^this^ first to make sure your reactive components are up to date before finishing the api call itself.
However, I still don't understand how it said "" instead of 0.
I'm using typescript (javascript strongly-typed) so it definitely wants to contain a number and not an empty string. Even in the declaration of my DTO the property is defined as (and expects) a number.

Using HTML Templates at server side

I am working on play framework with SCALA as backend.
Json data is given to the front end from the controller.
I want to add HTML as value of some fields of json.
This HTML will be kept as a template and data will be added in this template at run time.
I think i should put unique names in the HTML template and then these names will be replaced by the data which i want to add at run time. Ultimately, this HTML will be added in the json response.
Is my approach right? If not, what is the best approach to add data in an HTML template,add this template in json response and send this combined response to the front-end for further use?
Is it a good practice to use string replacement to add data in an HTML template?
I think as long as you use Play, you can put your HTML templates into app/views package. Let's say you call your template mytemplate.scala.html
You can parameterize this view as any Play view.
In the place in your code where you generate your JSON response you can then call mytemplate(parameters) to get html generated, Play will do all the work here for you. Then using play.api.libs.json.JSON object's methods and related facilities you can convert this html to JSON.
So in your controller's code you will have something like Ok(JSON.toJson(mytemplate(parameters)))
This is of course a sketch, so you will need to elaborate and try.

CQ5 Invalid recursion selector value 'data' (data.json.jsp)

Let's say I have a page in CQ5. I created this page using a template with a single component, call it tableComp, and I hit at url Test.html. The component contains its standard JSP file but the page template being used also contains a specific JSP for JSON or XML rendering of custom data, not page data.
This JSP file for rendering would be named something like data.xml.jsp or data.json.jsp. To hit this rendering JSP for the page Test.html you would call /content/{org}/desktop/en_US/{name}/Test.data.json or /content/{org}/desktop/en_US/{name}/Test.data.xml.
The XML/JSON JSP would be called which contains code to just get values and print to the screen XML or JSON. Ex: Blah
Now I want to display information to the screen as a JSON output when I hit a new file named data.json.jsp. When hitting data.xml.jsp it works correctly and hits the JSP. When I do the exact same process for the data.json.jsp I then get the following.
Invalid recursion selector value 'data'
Cannot serve request to /content/{org}/desktop/en_US/{name}/Test.data.json in org.apache.sling.servlets.get.DefaultGetServlet
Request Progress:
0 (2015-07-22 18:10:06) TIMER_START{Request Processing}
0 (2015-07-22 18:10:06) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
0 (2015-07-22 18:10:06) LOG Method=GET, PathInfo=/content/{org}/desktop/en_US/{name}/Test.data.json
I have tried adding a Pages.json.jsp file to the /libs/foundation/components/primary/cq/Page section as suggested in another forum but this did not help. The content of this Pages.json.jsp file was <%#include file="proxy.jsp"%>.
How can I get JSON to work for this type of request?
EDIT:
I have changed my original explanation to clarify my problem.
Looks like the request is being handled by the DefaultGetServlet which in turn uses the JsonRendererServlet to process your requests with .json extensions.
Since the JsonRendererServlet requires a numeric selector or the infinity selector, it throws the following error.
Invalid recursion selector value <<selector>>
However requesting /Test/_jcr_content.data.json would render the JSON data processed by the data.json.jsp instead of the DefaultGetServlet.

How can we construct custom URLs in HTML form with GET method?

I am using Django for making a website. I am using an HTML form with GET as the method.
The problem is that by default the get url is like this:
/search?name=user&place=place
But I want it to be something like:
my_site/search/user/place
How can that be done?
Why not use POST as method and retrieve the parameters in your view from request.POST? In this way they won't appear in your url.
Also, if you're expecting a list of results i recommend using ListView from views.generic, and in the dispatch() method you'll retrieve your parameters based on which you'll filter the user model (i guess).
It is better with a get request immo, but if you want something like: my_site/search/user/place it is easy, you just have to define the variables in your url and get the arguments in your function.
You can find more detail in django documentation
The only way you can do this in the browser is with Javascript. You will need to build the URL from the form contents. There are many mistakes you can make around encoding the values for the URL. You should be asking why you want to do it this way instead of using the QUERY_PARAMS as the form is doing.
Decoding it with Django isn't that hard, they are just variables in the URL pattern, but unless you have some kind of earth shattering new technology, you should let the browser send them to you without using JS to handcraft the URL.
Using the GET method send data via the web page. This means that the URL can be copied and rechecked at any time.

bindingResult.getAllErrors() vs bindingResult.getFieldErrors()

I am developing a application using Spring MVC 3.0 frame work, I have following requirement,
There are multiple form in one jsp page. I am using ajax to submit each form. But after submitting, each form will go to different controller. In controller I will validate input data if there is any error I need to send validation result back to jsp page. Right now I am storing errors into a separate list and sending back to jsp through json response. I am not sure whether to use bindingResult.getAllErrors() or bindingResult.getFieldErrors() to get list of errors in my controller. What's the difference between both?
getAllErrors()
By using bindingResult.getAllErrors you will get all errors, both
global and field ones.
getFieldErrors()
By using bindingResult.getFieldErrors() you will get all errors associated with the given field.
Here is a useful Link that may help you understand difference between each better.
getAllErrors() returns all errors, both Global and Field. getFieldErrors() only returns errors related to binding field values. I am not sure what a "Global" error is generated from, as I have never seen one.