I need to clear the contents of an observableArray that is located in one viewmodel while the user is in another viewmodel. Can that be done?
For example, lets say I have an observeableArray called myArray. myArray is located in TestPage1.js. The user does something to populate that observeableArray while on TestPage1 and then navigates to TestPage2.js. I need a way to clear the contents of myArray FROM TestPage2 so that when a user returns to TestPage1, no data bound to myArray is displayed.
Clearing the contents before leaving TestPage1 is not an option since the decision to clear or the contents of myArray is really based on what the user does.
I would use event aggregation. I have made one for SignalR, if you have no use for SignalR in your project you can use this one that has the server side functionally striped
http://jsfiddle.net/AV39k/
You subscribe to a event like
MyApp.eventAggregator.subscribe(MyApp.DeleteCustomerMessage, this.customerDeleted, this);
The complete framework can be found here
https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy
Related
I am working on an AR app in Unity and want to display information of an object. To display said information, the user has to be able to click/select that object.
I cannot find the line of code that creates the objects.
I have tried to use a snippet of the ARTabletopKit that handles the user's input to select an object.
If I am correct, the problem is that I cannot use the DebugCanvas-GameObject of the WorldScaleAR example as it does not contain any of the actual game objects.
As far as I can see the objects are created and placed here:
unityTile.Initialize(_map, tileId, _map.WorldRelativeScale, _map.AbsoluteZoom, _map.LoadingTexture);
PlaceTile(tileId, unityTile, _map);
At last I expect the method EventSystem.current.IsPointerOverGameObject() to return true.
Cheers!
You'll need to add a [GameObjectModifier][1] to handle the onClick. You can configure the modifiers to be added at runtime on the game objects in the Map Features area of the AbstractMap.cs script.
I would take a look at how it's implemented on the Data Explorer example.
I am using a FlexColumnLayout for my app.
In the mid column I need to access a controll of the begin column of the FlexColumnLayout. Here is the problem:
Since it is a different view I cannot use
this.getView().byId("myId")
My first solution was to use stable ID's, by giving the views (XML) IDs.
Like that I could use:
sap.ui.getCore().byId("application---viewId--myId")
At first it worked just fine, but now that I integrated my app into the fiori launchpad the first part of the stable ID (the part before "viewId") changed and when I transport into productive it will change again.
Is there a way to access the mid column controls without sap.ui.getCore().byId?
Or is there a way to load the first part dynamically so I don't need to change my IDs when tranporting?
Sadly I don't know how to reproduce a Launchpad for testing purposes, but for those who want to test their ideas about my problem, my FlexColumnLayout is build just like in the DemoApp: https://sapui5.hana.ondemand.com/#/entity/sap.f.FlexibleColumnLayout
Ok guys i found a solution:
this.getView().getParent().getParent()
returns the FlexColumnLayout. This has a method called "getBeginColumnPages", which returns an array of the views representing the begin column. Now that i can access the view in which my control is found, i can access it with the sap.ui.core.mvc.View.byId() method.
Now I have
this.getView().getParent().getParent().getMidColumnPages()[0].byId("myId")
Since the doulbe .getParent() doesn't seem to be ideal, please post a better solution if you know one : D
You have to use createId() function, this will return the complete ID of your control.
this.byId(this.createId("myid"));
I've been trying to search for information on how use the copyCard trello action, it looks like I should use Card.ApplyAction, but I am not sure if thats the correct way. I have not found how to set the needed data on the action to copy the card.
Is there a method in Manatee.Trello to copy a card or do I just do it all myself? If there is how do you use it?
To copy a card, you'll need the destination list. If you're just trying to put it in the same list, that's card.List.
Then you can just add a new card using the existing card as a source:
var card = new Card("<card ID>");
var copy = Card.List.Cards.Add(card);
Done!
Edit for completeness
The ActionTypes enum serves two purposes:
Identify the type of action when you get the list of actions (card.Actions) for objects that expose them (boards, lists, cards, etc.)
Filter actions that are included in the Filter() extension method.
You can find out more on the Manatee.Trello wiki
Another edit for more completeness
The card.ApplyAction() method is for web hooks. When a request is received, the content is deserialized as a string and passed to this method. It is an alternative updating mechanism from the default on-demand polling.
When I submit my form, if I do not select a value for my radio box then nothing is sent over to my command object for validation. I don't have issues with textFields or other input types.
class ApplicationCommand implements Validateable {
Map<String,String[]> questions = new LinkedHashMap<String,String[]>();
static constraints = {
questions validator: {val, obj, errors ->
for(String key : val.keySet()) {
errors.rejectValue("questions[${key}]",'required');
}
}
}
}
<g:radioGroup name="cmd.questions[1]" values="['Yes']" labels="['Yes']">
${it.radio}${it.label}
</g:radioGroup>
<g:textField name="cmd.questions[2]" />
With the above example, If i leave both fields empty and I submit I get the following
qusetions = [2: String[0]]
What I expect to see is
questions = [1: String[0], 2: String[0]]
Due to this issue, in my questions validator since key=1 is not populated I cannot validate it. The questions are dynamic all pulled from a DB so I cant hard-code anything in the validator such as if !questions.contains(1). Whatever data is populated into questions upon submission is what I have to assume the data is.
I have found 2 work-arounds, neither of which I like
1) Only for radio buttons, add a hidden field that will force a value to be populated if a radio is not selected. Horribly ugly
<g:hiddenField name="cmd.questions[1]" value="-" />
2) In my validator, I query the DB for all my questions and manually check for the existence of each one in the questions map. I want to avoid DB queries in my validators.
So while my 2 work-around options do work, I don't feel like I should have to resort to them.
I don't think this is a limitation of command objects or Grails; I think it's a limitation of HTML. I see the same question popping up in PHP.
The essential problem is that your command object doesn't know how many questions there are, but is responsible for making sure they are all there. I can think of a couple of (additional) ways to deal with this limitation:
The quick and easy way would be to put a single hidden input with the number of questions into your form. Also ugly, and open to alteration by the end-user.
The other option is to promote questions into a Domain so that the number of questions is known ahead of time, and is made available to your command object via a field or method. Then your command object can ask your questions, "How many are there supposed to be? Okay, did I get that many from the view?" This is similar to your #2 but without having to retrieve an entire collection and iterate it. This also opens up a path to perform further validation on each question (e.g., don't allow text into a numbers-only answer).
This does require hitting the DB, but it's the only way I can think of to validate the number of questions without relying on input from the view. The nice thing is that you can make it a very shallow hit, and hitting the DB can be very quick if you do it properly.
Ok, Here is the problem.
At the time user signup, user need to provide info such as:
-Email:______________ -UserName:____________
-FName:______________ -LName:_______________
-Address:____________ (User can have option to update Address lately)
....
-Captcha:__________
[Sign Up] [Reset]
Now suppose that user already got an account & they want to modify their info, then the Gui Could be 40% similar to the the above one.
-FName:______________ -LName:_______________ [Update Name]
-Address:____________ [Update Address]
....
My question is how to design GWT Gui in such a way that we can reuse the Gui components and the Action in both situations?
Maybe put all GUI into 1 page & have 2 different params: 1 for handling Signing Up Ex: #profile;actionParam="signup", & the other for Updating Profile Ex:#profile;actionParam="modify".
We can also use PresenterWidget but I think PresenterWidget is for using the exact same code everywhere, but in my case the Gui need to be modified a bit.
In Java we can do like Parent and Child Inheritance, but I am not sure if we an do similar things like that in GWT?
Can u find a better solution?
You can use the exact same view (widget) and simply hide some fields based on your criteria. You can also group these extra components in one container, so you can hide/show them with a single call:
.newUserPanel.setVisible(user == new);
You can extends widgets in GWT - all of the "standard" widgets extend and implement something - but in this use case the benefits are probably too small to justify two separate views/widgets. But it's possible if you decide to go this route.