Binding to observable collection getting element onTapp - binding

i use a observable collcetion to bind data to a GridView (with an itemTemplate). The template includes an item that can be rightTapped. Is there any nice way to get the element (the one in the observable collection) in the rightTapped event handler?
Thank you

Yes , youcan get the value from senderitem.datacontext (you would need some typecasting).

Related

Add UNKNOWN eventstreams to CEP Engine and get a list of all properties (payload) of this event

I want to be able to add event streams where I don't know beforehand what kind of properties the events have. So I don't know before if there is an integer ID or if there is a date timestamp and which payload might be there. As soon as I add such an unknown event, Esper should examine the stream and return the contained properties of the stream to me.
Thank you very much. That actually helps me a lot. But a function which returns all property names directly does not exist, does it? So I would have to use dynamic parameters (trial and error) until I know which ones exist in the eventstream.
Thank you for your help :)
See similar to Add Sensorevents to CEP Engine and get a list of all properties
In the case that you don't have some or all of the properties, you can add the stream without any properties or with those properties that you know that the events have. Here is how to add a stream where you don't know any properties in advance:
#public #buseventtype create schema MyStream()
You can now use EPEventServive#sendEvent to send events.
You can use this stream in various ways. You can simply select the event.
select * from MyStream
Or you can use the dynamic property names, those with a '?' questionmark appended to them. This can refer to properties that may or may not exist.
select id? as id from MyStream
The "id?" returns an Object-type value. You can use "cast" to make it, for instance, a double-type value to total up.
select id? as id, sum(cast(someNumericProperty?, double)) as total from MyStream where
When the property doesn't exist the "?" expression returns null. There is an "exists" function that returns true when the parameter that is a dynamic property exists.
I don't think the Esper runtime actually knows about any dynamic property until the EPL attempts to use that dynamic property. The runtime doesn't inspect any event for actual properties.
You can add your own user-defined function that determines what the property names may be for your specific event underlying. So when the underlying is a java.util.Map the user-defined function can return "event.keySet()".

Binding value of UISelectOne and UISelectMany to same property

I'm trying to create a dynamic survey application in Prime Faces. I have a list of Question Objects that each contains a list of AnswerChoices. These are given to the f:selectItems value attribute. This is fine. The question object also contains a List of selectedValues which is given to the relevant selectOne/many component.
Because I'm looking to be generic, there will be questions that have multiple selected values and also some that have only one selected value. I wanted to be able to point the selectOne and selectMany components to the List of strings within the relevant Question object that represents the selectedValues.
This works ok for the selectMany component, but not for the selectOne component which needs to be pointed at a singular object rather than a list. Is there an easy way around this that I'm missing - as I'd like to only have one object representing the selectedValues if possible
You can use brace notation to bind the value to a list/array item at a specific index. The below example binds the value to the 1st item of the list/array.
<h:selectOneMenu value="#{bean.selectedAnswers[0]}" />
There's however a caveat: you need to prepare the list/array with the single item yourself during bean's (post)construction. JSF/EL won't do that in case of a <h:selectOneMenu>.
E.g.
#PostConstruct
public void init() {
selectedAnswers = new ArrayList<Answer>();
selectedAnswers.add(null);
}
It doesn't harm to reuse this preinitializated property for UISelectMany components by the way.

jQuery UI Autocomplete question on label and value

In the label we have item.ID + '-'+ item.Description
the value is item which is the object returned from the service.
When a selection is made 001-MyChoice for ex. from the autocomplete, the value which is the datacontract object is bound to the autocomplete field as [Object object]. How can I get 001-MyChoice to be bound for the selection ???
Pls help..
It's difficult to tell when you haven't posted any code to review. What format is your data returned from the service? JSON, XML?
I'm sure you're already looked at this link, but here it is just in case:
http://jqueryui.com/demos/autocomplete/#remote
Post some sample code of your js and some sample data of what your service returns for a better answer.
The autocomplete tags returned from your web service need to contain the tag 'term' and I think "ID", then the default call can help pull them out. Although not a perfect example if you look at the Jasonp example in the jQueryUI docs, that may help.
This is from memory but something like
{"term":"dog", "ID": "123"}, {"term":"cat","ID": "2"}
So you have 001-MyChoice as the label and you want it bound as the value?
Then don't specify the object returned as the value. Label and value are not required by the autocomplete. You can specify both if you want one in the dropdown select (label) and the other (value) used as the value of the select.
If you want the select item and the value to be the same, then put the same item in either the label or the value property.
From the jquery autocomplete docs:
The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.
If you need to use the datacontract object, then just assign it to a variable in the select callback function of the autocomplete and you can use it as that.

How MVC Update Model works with incomplete objects?

I have a view that is bound to an object called "Requisition"
On this view we are only modifying is child records.
My question is: When I submit the form I have the object requisitionForm, and this object is only partially complete.
How do I save just the new changes?
Should I take the requisitionForm (incomplete) and merge it with requisition (complete) ?
thanks!
Remove the requisitionForm parameter, and call UpdateModel(requisition)
Is this what you want? http://www.joe-stevens.com/2010/02/17/asp-net-mvc-using-controller-updatemodel-when-using-a-viewmodel/

Get the display value from a DropDown

I'm trying to access the values in the FormCollection inside of an action. I can get the value field by doing:
var value = formCollection["MyDropDownList"];
But I can't seem to find a way to get the display value. Am I missing something obvious? A cast perhaps?
Getting text from an HTML drop down selection list using JavaScript code
To get the text from each option is slightly trickier. We use the selectedIndex property of the selection list to capture the selected option and then pass this value to the options[].text property.
Here is the code
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
I don't think there's a way to get the display column from the formcollection. Basically, the formcollection is an easy way to interrogate the Request object (Request.Form, Request.QueryString, etc.) and the only thing that goes into that are values from input fields.
If you really need to get the display text, you would have to get it from whatever collection you bound the list with and access it via the key (your selected value from the formcollection). For example, if it's a dictionary collection that you bound to the list, use that same dictionary to lookup the value based on the key.
I would need to know more information as to how you're binding the dropdown to help you further.
That's the normal behaviour. When a form is posted, only the name-value collection generated from the form fields are sent to the server. And of course the inner text of the option tag doesn't belong to that collection.
you do it ok, dropdown list sended shows value of selected item not displayed text of selected item...if you want(from some reason, because I am asumming you are filling that dropdown on model right? :)) to see send a display text also, maybe you can put it in hidden field with javascript on every change of selection in dropdown...
cheers

Resources