I have to pass mobilId (int) to the method UpdateStatus, I am not sure how to do that
Update_Completed += new EventHandler<AsyncCompletedEventArgs>(UpdateStatus);
protected void UpdateStatus(object sender, AsyncCompletedEventArgs e, int mobilId)
{
Define(Id, e.Cancelled, e.Error, mobilId);
}
Both these methods are in the same file.
Kindly let me know if there'a any way to do it.
What does the initial call look like? There is a UserState option you should be able to set on the first method call. It is of type object so it can be anything.
Related
I need to solve a simple problem, but yet I have not been able to found out any solution yet.
I have a simple DropDownChoice with AJAX onChange() JS event. I need to add a confirm box before the onUpdate() action is done - this is not difficult, BUT I need to display the confirm box only if the new selected value of the DropDownChoice is X (one certain value), and do not display the confirm box in any other case. Is it doable?
Short example snippet:
DropDownChoice<Integer> choice = new DropDownChoice<Integer>("id", new Model<Integer>(0));
choice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
#Override
protected void onUpdate(AjaxRequestTarget target) {
// do some stuff
}
#Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new AjaxCallListener() {
#Override
public CharSequence getPrecondition(Component component) {
return "return confirm('Really?')"; // I NEED THIS DISPLAYED CONDITIONALLY
}
}
}
}
I don't know how to access the "choice" model object (converted input...) with the proposed value to add it to a condition in updateAjaxAttributes() method.
Thank you.
I think you should go for a JavaScript-based solution. The code of AJAX call listener is executed in a scope where you can use variable attrs. This variable contains the parameters used to perform AJAX call, including the id of the component. In this way you could check for selected value.
See more at http://wicket.apache.org/guide/guide/ajax.html#ajax_5
I have the below event that gets fired upon geocoordinatewatcher object position changed event.
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
//do the stuff here
}
Now when user clicks on any location on the map I want to call the above method and do the same stuff everytime.
Any idea how do I achieve this ?
Either call your event handler manually:
var position = new GeoPosition<GeoCoordinate>(DateTimeOffset.Now, new GeoCoordinate(32, 64));
this.watcher_PositionChanged(this, new GeoPositionChangedEventArgs<GeoCoordinate>(position));
Or rewrite your event handler to put the logic in another method, then call it:
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
this.UpdatePosition(e.Position);
}
private void UpdatePosition(GeoCoordinate coordinates)
{
// Do the stuff here
}
This way, you just have to call UpdatePosition whenever you feel like it. I'd recommend this solution, it's way cleaner than the first one.
Could you show me the way or the idea how to execute biding data every 10s??
Let's see the code below:
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
proxy.DanhSachPhongChoiCompleted += new
EventHandler<DanhSachPhongChoiCompletedEventArgs>(proxy_DanhSachPhongChoiCompleted);
proxy.DanhSachPhongChoiAsync();
}
void proxy_DanhSachPhongChoiCompleted(object sender, DanhSachPhongChoiCompletedEventArgs e)
{
Room[] table = e.Result;
listDSPhong.ItemsSource = e.Result;
}
We can see: ater my page loaded, the binding data will execute ONLY ONE TIME. I need to call 2 methods below every 10s. How should I do? Thanks for teaching me!
proxy.DanhSachPhongChoiCompleted += new
EventHandler<DanhSachPhongChoiCompletedEventArgs>(proxy_DanhSachPhongChoiCompleted);
proxy.DanhSachPhongChoiAsync();
You can use e.g. DispatcherTimer class.
Here's the sample:
https://stackoverflow.com/a/3266071/126995
You better start your timer in NavigatedTo, and kill it in NavigatedFrom.
P.S. I suspect there's a memory leak in your code. Please read this.
you can use Microsoft's reactive library
http://msdn.microsoft.com/en-us/data/gg577609.aspx
and do something like this :
public void callfunction()
{
IScheduler scheduler = NewThreadScheduler.Default;
scheduler.Schedule(TimeSpan.FromSeconds(5), new Action<Action<TimeSpan>>(myRepeatingFunction));
}
private void myRepeatingFunction(Action<TimeSpan> action)
{
//process here
action(TimeSpan.FromSeconds(5)); // five second interval
}
Hi all wicket pros out there,
I would like to get extra parameter I added to the AjaxRequest in the respond(AjaxRequestTarget target) method of a AbstractDefaultAjaxBehaviour.
I build the Wicket.Ajax.get(...) call by myself and I could manage that the respond(AjaxRequestTarget target) method of the AbstractDefaultAjaxBehaviour is invoked, but I get stock in how to get the extra parameters I added in my js call.
So here the code what I'm doing:
js that is called onSelect:
Wicket.ajax.get({'u':'callbackUrl','c':'componetId', 'ep':{'objectId':'OBJECT_ID'}});
java snippet of the AbstractDefaultAjaxBehaviour:
onSelectBehavior = new AbstractDefaultAjaxBehavior(){
#Override
protected void respond(AjaxRequestTarget target) {
//here I want to get the OBJECT_ID I added in the Wicket.Ajax.get call above
}
};
The respond() method is invoked as expected, but I don't know how to get the OBJECT_ID.
Actually I'm not sure at all if I added the extra parameter in the right way to the wicket.ajax.get call.
In Wicket 1.4 I added the extra parameters as a url query string like ajaxCallUrl...?objectId=OBJECT_ID and in respond() I got them back from the RequestCycle RequestCycle().get().getRequest().getParameter('objectId')
If anyone could give me a hint, I would appreciate it :)
Thanks in advance,
Ronny
Your approach is correct. You should be able to get the parameter like this:
#Override
protected void respond(AjaxRequestTarget target)
{
getRequest().getRequestParameters().getParameterValue("objectId");
}
See my answer to this question for passing parameters directly from Wicket without constructing the ajax call yourself.
I'm trying to make an ApplicationBarMenuItem that, when clicked, switches my bing map between RoadMode and AerialMode. my pseudocode looks something like this:
private void changeMap_Click(object sender, EventArgs e)
{
if(map1.Mode == RoadMode)
map1.Mode = new Microsoft.Phone.Controls.Maps.AerialMode();
else
map1.Mode = new Microsoft.Phone.Controls.Maps.RoadMode();
}
However, it says I cannot use RoadMode, which is a 'type', like a variable. Does anyone have a way around this?
Because RoadMode is a class and you are trying to compare class to an object.
Try (edit)
if(map1.Mode is RoadMode)