We've been slowly getting accustomed to ExtJS and we recently started using view models to bind data to our form panels. In general we are trying to keep our ExtJS models consistent with our backend java models, and any conversion required is done via view model formulas. When viewing general data this works perfectly however when we want to show more specific data that don't really exist in any kind of model, we are not sure how to approach their loading and creation in the client. For example:
I have a folder model with id and description properties. When loading a folder model via a read request the model loads the description from the database etc. Same thing with a User model. Two properties id and username. My question is, what if I have a form panel where I show the user and his associated folder. As far as the database layer is concerned, there is a 1:1 table where a user id is connected to a folder id to match the user and his personal folder. However we do not have this information available in any of the models. There is a specific service called getUserFolder which returns a folder object for the specific user id given. How should I put this in my panel's view model and how do I tackle the loading process?
Should I create a new model representing the table and use a get request to get the association, then use formulas to get the matched folder id for the given user? Should I just use a normal Ext.Ajax.request to get a folder id and then load the folder model? Should I create a general service that returns all the data (user and folder) and then match them in the client side on the request callback via setData of both models? What is the best practice?
TL;DR: Loading model data in viewmodels works fine but how to tackle loading non-model data in view models? They are only required in specific scenarios and are not included in the model's creation.
Your task has very little to do with view. It's all model, data model :) There is a concept of associations in ExtJS, including the 1:1 scenario. So I'd recommend to look into it.
Data binding and the ViewModel that powers it are powerful additions to Ext JS.
Ext.create('Ext.panel.Panel', {
title: 'Simple Form',
viewModel: {
type: 'test'
},
layout: 'form',
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
bind: '{firstName}' // uses "test" ViewModel from parent
},{
fieldLabel: 'Last Name',
bind: '{lastName}'
}]
});
Related
I currently have a form that allows users to upload data, however, I want to save the path variable to the database for that object.
The thymeleaf form action is as follows.
<form th:action="#{/homepage/{room_id}/saveLayout(room_id=${Room.room_id})}" th:object="${layout}" method="post">
This is the controller that the form corresponds to
#PostMapping("/homepage/{room_id}/saveLayout")
public String saveLayout(#ModelAttribute("layout") Layout layout, #PathVariable(value = "room_id")long room_id) {
layout.setroomid(room_id);
layout.Service.saveLayout(layout);
return "redirect:/homepage";
}
The idea is that when a user sends the form after clicking on say room 2, the URL should be
homepage/2/saveLayout
However, the issue is that the URL does not contain the ID of the room, instead it looks like this
homepage//saveLayout
Which in turn causes spring boot to return an error saying the URL contained malicious content '//'. Even after removing the path variables and hard coding an integer 2 into the setroomid method, the room id does not change in the database. I have another controller which directs the user to the form to input the data, this adds attributes layout and room to the model. There are no red underlines in either of the HTML documents within the thymeleaf code. My setroomID method is
public void setroomid(long room_id){
roomid = roomid;
}
I should also make it clear that the actual data uploading works, however the roomID for a layout remains unchanged. If anyone is able to recommend any changes to make this work, or suggest an alternate way of binding a roomID to a layout in the database then it would be appreciated, thanks.
I am trying to get the modified content after the given time from google sheets. Nowhere I can found the api to get the data. What i can see is getting modified date alone from the drive Api. How can I get the data using Drive or Sheets Api? Give me the suggestions if Possible
Google Drive keeps a track of revision history of files that are contained on it. There is however, no way to obtain the revisions from a request alone.
Google allows for you to receive email notifications whenever a user makes an edit to your sheet, which you can set up by completing the following steps:
In the Spreadsheet's web view, click Tools -> Notification rules...
Under Notify me at myemail#address.ext when... select Any changes are made
Under Notify me with... select Email - right away
Click Save.
You should also be aware that you will not get a notification for edits made to the sheet by you - notifications are only received when another user edits the sheet. Whenever you get an email notification, you will receive a link to view the changes to the spreadsheet in the form of a read-only web view link.
You can work around this programatically, though there isn't one right way and it can be quite complicated. You can use the Revisions: list method of the Drive REST API to get the information about the user that made an edit, as well as a list of links which you can use to export that revision of the sheet to another MIME Type, as shown below in the request response.
Requesting:
GET https://www.googleapis.com/drive/v3/files/SPREADSHEET_ID/revisions
with revisions/exportLinks,revisions/lastModifyingUser/emailAddress as the fields field and replacing SPREADSHEET_ID with the ID of the spreadsheet will give you a 200 response:
{
"revisions": [
{
"lastModifyingUser": {
"emailAddress": "username#domain.ext"
},
"exportLinks": {
"application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=revisionNumber&exportFormat=ods",
"text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=revisionNumber&exportFormat=tsv",
"application/pdf": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=revisionNumber&exportFormat=pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=revisionNumber&exportFormat=xlsx",
"text/csv": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=revisionNumber&exportFormat=csv",
"application/zip": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=revisionNumber&exportFormat=zip",
"application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=SPREADSHEET_ID&revision=1&exportFormat=ods"
}
}
]
}
With the links to individual changes, you can fetch and compare the different versions of the Sheet using Apps Script, and output A1 notation of the cells that have different values between versions. This, with the email address from the original Revisions: list request, is enough to compile a file or a log containing.
You can put this into a simple onEdit() trigger bound to the sheet will allow you to automatically get the changes each time a user edits the sheet.
Basically it's a requirement modeling project, I have data of requirement already
For example
I have data in database as
Class Name= Users
Variables= id, name, Address etc
Methods= Sign In (), Sign Up () etc
I want to generate class diagram of this data at run time ( like when I click model requirement button then it should create the class diagram from this data )
Any plugin or API to do this ? I am creating this project in JSP and Google App engine.
Any API or library that may take Data (Fetched from database ,Not the SOURCE CODE of my Project) and generate a class diagram from it on HTML file or any other format.
Thanks.
Some thing like this (more than 1 classes of course and links between them)
![image]: https://i.stack.imgur.com/Khv3d.png
I developed a shopsystem. there is a product page, which lists the available items filtered by some select menus. there is also one item detail page to view some content about each product. the content of that page will be loaded out of an xml property file. if one would click the link in the listview of an item, to view some details, an item specific GET parameter is set. with the parameters value, i can dynamically load the content for that specific item from my properties, by altering the loaded keys name.
so far so good, but not really good. so much to the backgroud. lets get to some details.
most of all, this is some SEO motivated stuff. so far there is also a problem with the pageinstance Id in the url for statefull pages, not only because of the nonstable url, also because wicket is doing 302 redirects to manipulate the url. maybe I will remove the statefull components of the item detailpage to solve that problem.
so now there are some QR-code on the products being sold, that contain a link to my detail page. these links are not designed by myself and as you can imagine, they look a whole lot of different like the actual url. lets say the QR-code url path would be "/shop/item1" where item1 would be the product name. my page class would be ItemDetailPage .
I wrote an IRequestMapper that I am mounting in my WebApplication#init() that is resolving the incoming requests URL and checks wether it needs to be resolved by this IRequestMapper. If so, I build my page with PageProvider and return a requesthandler for it.
public IRequestHandler mapRequest(Request request) {
if(compatibilityScore>0) {
PageProvider provider = new PageProvider(ItemDetailPage.class, new ItemIDUrlParam(request.getUrl().getPath().split("/")[1]));
provider.setPageSource(Application.get().getMapperContext());
return new RenderPageRequestHandler(provider);
}
return null;
}
So as you can see, I build up a parameter that my detailpage can handle. But the resulting URL is not very nice. I'd like to keep the original url by mapping the bookmarkable content to it, without any redirect.
My first thought was to implement an URLCodingStrategy to rebuild the URL with its parameters in the form of a path. I think the HybridUrlCodingStrategy is doing something like that.
After resolving the URL path "/shop/item1/" with the IRequestMapper it would look like "/shop/item?1?id=item1" where the first parameter off course is the wicket pageinstance Id, which will most likely be removed as I will rebuild the detail page to be stateless :(
after applying an HybridURLCodingStrategy it might look like "/shop/item/1/id/item1" or "/shop/item/id/item1" without pageinstance Id. another Idea would be to remove the second path part and the parameter name and only use the parameters value so the url would look like "/shop/item1" which is then the same url as it was in the request.
Do you guys have any experience with that or any smart ideas?
The rewuirements are
Having one fix URL for each product the SE bot can index
no parameters
stateless and bookmarkable
no 302 redirects in any way.
the identity of the requested item must be available for the detailpage
with kind regards from germany
Marcel
As Bert stated, your use case should be covered with normal page mounting, see also the MountedMapper wiki page, for your case a concrete example:
mountPage("/shop/${id}", ShopDetailPage.class);
Given that "item1" is the ID of the item (which is not very clear to me), you can retrieve it now as the named page parameter id in Wicket. Another example often seen in SEO links, containing both the unique ID and the (non-unique, changing) title:
mountPage("/shop/${id}/${title}", ShopDetailPage.class);
Regarding the page instance ID, there are some ways to get rid of it, perhaps the best way is to make the page stateless as you said, another easy way is to configure IRequestCycleSettings.RenderStrategy.ONE_PASS_RENDER as the render strategy (see API doc for consequences).
I am trying to create a free form BIRT report. The report is not consisted to rows which have the same columnNames in each row.
Instead, it is a free form report, which will be of the following form.
"Name: {FirstName} {LastName} Addess : {Address}
Phone# {Phone#}
....
....
"
I am using a scripted datasource, which essentially returns the Map containing the name value pairs of {FirstName, LastName, Address, Phone, and other fields}..
But I am not sure how to set the variables and how do I get the FirstName, LastName etc.
Should I try to use dynamic text.
I don't know of any way in which BIRT can handle non row related data.
Here's my open script of the dataset.
open:
util = new Packages.test.ReportsUtil();
reportsVO = util.getReportVO("ABC");
in fetch:
if(currentrow < totalrows) {
dataSetRow["FirstName"] = reportsVO.getPropValue("identity.FirstName");
dataSetRow["LastName"] = reportsVO.getPropValue("identity.LastName");
currentrow++;
} else {
return (false);
}
But I am not sure of how do I get access to the FirstName and LastName in the main layout page.
Thank you
The goal of a scripted data source is to allow you to leverage the logic inherent in your data model and benefit from any business rules that manipulate that data. In the end it still wants the data to be formed into a rather traditional row-based set.
You mention dynamic text and I think this would be a great use for the Java-based event handlers. You can use the logic in the Java object you had bound to the scripted data source to instead tie to an event in the life cycle of the report and get your non-relational data that way.
You can even call your Java object directly from a JavaScript event handler (much easier to plug into via the IDE) using the JS "Packages" construct.
There are many examples to help you get this done at the BIRT Exchange.
I did something similar (BIRT 3.7) but I used row["colName"] instead of dataSetRow["colName"] and that seems to work. I have my data in a list, and then each list item is a grid. I set the data binding in the list to the data set. The grid is able to see the value as row["colName"].