I have the following setup for a module:
Shell (has a router)
Workspace module
Screen1
Screen2
I want the workspace to show a couple of different views, collect information from them, and POST some data to my api. I've started down the path of having a child router on the workspace, but that means the screens are so decoupled that I have no means of getting at the screen viewmodel objects. This means I have no way to communicate back to the workspace that they've done what they needed to. I'm also concerned about the "lifestyle" of the various viewmodels - I'd do something like import workspace = require('workspaceViewMode'); but I'm not sure what instance of the workspace that would get.
What is the correct approach? Is a child router actually the best method, or should I be trying to use the "activator" (struggling with docs for that) directly?
Well from trying it out and poring over the documentation, it does seem that because the workspace has a child router, it's instance stays around during navigation. I tested this by having it assign itself a guid on activation, and checking that guid on the imported instance in each screen viewmodel.
So my solution is to provide methods on the workspace for the screens to call, whereupon the workspace will decide what to do with them.
Phew!
Related
I am writing a SwiftUI app that needs to read an external SQLite database. I just need to open the database, query the database, copy values into an array and close the database. Then I need to load the text from one variable in the array to the buttons in a view. I am using the SQLite.swift library but I'm not sure how to do it.
I don't have any code yet but I have loaded the SQLite.swift package and just need to write my DatabaseHelper class and then run it when the View is opened. If anyone can help please reply! :)
Bear in mind that I haven't actually done this, but will have to in the near future. You are going to have to accept the fact that you need to take baby steps and throw out half your work, perhaps multiple times, until you get a satisfactory solution.
I would start by opening your db outside swiftui, probably in the app delegate class. Then stick all your values into the environment object and attach that to your content view
let contentView = ContentView().environmentObject(your_stuff_here)
Down in Swiftui you can extract the details from the environment object and add them to your button.
That should at least get you going.
At my new job I'm forced to use Adobe AEM and everything that comes with it.
But because everything is new to me and to my team, we are having some major dificulties understanding what are the best practices and what's the correct "code workflow". I've read everything that I could, but something's messing with my head and I just can't figure it out alone.
My question is:
When I don't want to work with the JCR tree, and I just want to make a component for a specific user (not a real CMS component, I guess), I can't understand how I'm able to reload my component information (based on some Model).
So... imagine I have an authenticated user that has N Cars.
And I've developed a component that shows the information of one of those Cars. The selected Car can change and I want to update the component with the selected Car information.
By default, when the page loads, the Car number 1 is loaded.
First question: How should this first Car be loaded?
My first try on this one was to backup my component with a WCMUse extension, and on the activate() method I would set my default Car properties.
But this seems odd to me, because I don't know how I connect this class to my Spring Controller...
I've read that ResourceModel can be used for this, but that it would map its properties to a Car JCR node that I don't have.
Second Question: Imagine that the first Car is correctly loaded and I call a method on my Spring Controller to update it.
What needs to be done to reflect this change on the Car information component?
So, to finish, I guess my main 2 problems are: What should be the model for the Sightly component, and how does the component refresh with the updated information.
Thanks a lot.
Welcome to AEM world silva, sad to listen that you are forced to work in AEM.
Though it might appear difficult initially , a developer worth his salt can gain enough expertise to work with AEM in around 6 months. For a Java developer it is difficult to relate things.
Coming back to your problem: If I understood you well you don't want to store you data in JCR and you want to hit your Spring controller to fetch the data.
Answer to First question: Ideally in AEM the data resides in JCR, it may be a User node and then Car0,Car1... CarN child nodes, here all car details are stored on car node as properties. It is all about how you want to structure your content.
If you plan not to store data in JCR you can create a OSGI service which can get the data from your spring controller and pass on to the sightly component.
Answer to Second question you can pass a parameter to your sightly component and get the relevant view of carN, Checkout Passing parameters to sightly .
You also can create href's which will load the same page and pass on some request parameter which you can read in your WCMUse (WCMUsePojo in AEM 6.2) extension activate method.
Keep learning keep helping, Cheers!
Lets try this explanation again...
I'm new to polymer (and getting back into web dev after a relatively long absence), and I'm wondering what the recommended approach might be to more closely manage object state while employing 2 way databinding. I am currently consuming rest API (json) objects. My question is if polymer keeps a copy of the original object before initiating updates to the bound object's properties/attributes...so one might be able to easily undo the changes? While allowing 2 way databinding to work its magic is often desired, there are cases where I'd like to prevent / delay changes to the object / DOM until the user approves the changes (say via the paper-dialog component for instance). I suppose one could make a temporary copy of the object and bind fields to that version, and then only persist the changes back to the source object upon user approval. In any case, I'd be interested to hear thoughts and see an example or two of recommended approaches (especially if I am off-track with my ideas!)
I suppose one could make a temporary copy of the object and bind
fields to that version, and then only persist the changes back to the
source object upon user approval
This.
Consider that view-models are essentially different from pure data-models (sometimes called business-data). Frequently, the differences are irrelevant and one can use them interchangeably. However, be aware of scenarios where the view-model is distinct (uncommitted user edits are a good example).
The notion of a field editor that requires approval from the user is purely UI/View oriented. Whatever data is managed in that modality is purely in the domain of the view, and fetches/commits to the business-data should be discrete.
I want to attach YUI modules synchronously.
Given the YUI modules are already on the page
When I run: console.log YUI().use('base').Base
Then I get `undefined`
However,
When I run: YUI().use('base', (Y) -> console.log Y.Base)
Then I eventually get the Y.Base ctor function
It looks like loader is attaching async as it works fine using the callback method. IIRC the first method is supposed to work too though. What am I missing?
If you're using YUI in a controlled environment like Node.js, then you should be able to use useSync configuration:
YUI({ useSync: true }).use('base').Base
But in a browser, or any other client runtime you should stick to the asynchronous nature of Y.use so loader can do its job of computing the proper list of modules to be attached based on the feature detections etc. Having the modules included manually in the pase is just not enough. Imagine the scrollview-base in IE, which requires an special module called scrollview-base-ie, unless you do detection when building the initial markup that includes that module only when running in IE, you will have a missing module. Again, stick to the asynchronous pattern when loading stuff.
YUI modules really want to be called through a Y object in a callback. If you know for sure that all the code you need is loaded on the page, you can attach them all synchronously with a use *. See https://github.com/evangoer/yui3-cookbook/blob/master/examples/loading/use_synchronous.html for an example.
I am using wxWidgets to download the contents of a website into a wxHtmlWindow control. This works flawlessly, except for one thing. The entire gui seems to freeze while the data is being downloaded, which is highly problematic for my application. In most other wxWidgets class methods, events continue to be processed automagicly for you even if the call in question is said to be blocking. This does not appear to be the case here, and I am wondering how I might tell wxWidgets to download the page in the background? I am currently using the LoadPage method.
I guess I could use a second thread, but with the restrictions that wxWidgets imposes on changing the state of any window through any thread other than the main one makes me hesitate to dive into this. Is there a better way? The raw http class, for instance, does not block the window while it's downloading so I don't understand why wxHtmlWindow, which surely must be using the raw http class internally, does not have the same behavior.
Unfortunately wxHtmlWindow uses synchronous sockets to fetch contents of a URL. Call hiearchy goes like this: wxHtmlWindow -> wxHtmlParser -> wxFileSystem -> wxURI -> wxHTTP -> wxHTTP::GetInputStream . The GetInputStream method will use the open a socket in blocking mode.
You will need to use a separate thread to fetch the contents of a website.