Coded UI Controls need to refresh - asp.net

I am using a coded UI testing harness that looks at a jQuery grid that we have written. The problem that I am encountering is that when the grid pages, the coded ui keeps track of the old controls when I try to call the paging again. I guess an example would explain it better:
BaseMap.MSMaintenanceMap.PageNext();
BaseMap.MSMaintenanceMap.PageNext();
this is the code that I am trying to get to work. The problem is here in the generated designer file:
if ((this.mUITitlePagingRowRow == null))
{
this.mUITitlePagingRowRow = new UITitlePagingRowRow(this);
}
When I change it to this:
this.mUITitlePagingRowRow = new UITitlePagingRowRow(this);
it works every time. Problem is when the uitest gets re-generated, this reverts back for obvious reasons. Is there any additional parameters that anyone knows that I can put in the .uitest file to always get the latest version of a control?

Add AlwaysSearch to the SearchConfigurations of the control, this forces the test not to cache the control but always look for it using the defined properties. Hope this helps.

You can refresh the map from your test method. So when you are calling the method in the partial class for a second time just put something like BaseMap BaseMap = new BaseMap(); Then this will refresh the map and you can call BaseMap.MSMaintenanceMap.PageNext(); without the refresh problem.
Another way around this is to not rely on BaseMap.Designer.cs. You can manually write the method in the BaseMap.cs partial class. This does not get generated. Record the PageNext() object into the map. Then write a method like this:
public void PageNext()
{
BaseMap = new BaseMap();
Mouse.Click('TheObjectYouRecorded');
}
Hope this helps.

Related

How to initialise controllers using provider state in flutter

I recently refactored half my app to use the provider pattern and i now have a problem. The main issue is that i need to initialise controllers in the init (e.g. a text controller to have an initial value or the list size of a tab controller)
How am i meant to init Controllers if the data i need has to come from the state in the build method.
For example.
// This must go in the build as it requires state
myTabsController = TabController(length: myState.list.length, vsync: this);
I'm initialisng the controller every time it builds now... How am i meant to put this in the init but still access the state variables (as there is no context).
I've tried using the afterFirstLayout() callback from the AfterLayoutMixin library but that just causes more problems. Currently with the tab bar it flashes error as no tab initialised for the first frame and then displays properly when the afterFirstLayout is called and initialises the tab. This seems like a hacky fix
I would like to learn more about how to use this pattern properly and what would be the best solution to this problem.
Feel free to ask me to clarify more.
Thanks for your help.

How to export a gwt-openlayers map as an image

We have gwt webapplication, showing map, implemented with gwt-openlayers.
I would like to implement a function to export the current map as an image (for example png).
I'm aware of this example from openlayers, but I struggle getting it done with gwt.
https://openlayers.org/en/latest/examples/export-map.html
Help would be appreciated
After more trial & error I found this solution which partly solves my problem:
https://stackoverflow.com/a/25486443/6919820
However, after closing the print dialog, the printed layout remains as some kind of overlay on my previous window. So my approach was to create a new map and copy all relevant data from the original one. Then print the new map and destroy it afterwards.
buttonPrint.addClickHandler(event -> {
// mapPrintLayout contains my new MapWidget
print(mapPrintLayout.getElement().getInnerHTML());
mapPrintLayout.destroy();
});
public static final native void print(String html) /*-{
top.consoleRef=$wnd.open('','_blank', "", false);
top.consoleRef.document.write(html);
top.consoleRef.print();
top.consoleRef.close();
}-*/;
It works, but I'm not convinced by my approach. Maybe there are better ways to do it.

Update shiny input from java script

I've looked around and tried a few things but I can't seem to get it to work. I want to be able to update the value stored in input$someVar from a bit of js code. What I need to on a certain element click, I need to update the input$someVar value. I know there are functions like "updateSelectInput()" but those are called from the server.
I can physically change the value of the data in the HTML that is used int he data attribute and that is displayed, but the server doesnt see this as a change and the input$someVar stays the same.
I have tried
var selectBind = Shiny.inputBindings.bindings[5];
selectBind.binding.setValue('#loc', newValue);
within an event handler, where #loc is the id of the input element, in hope that I could do it that way but this gives me an error.
Is there a way to do the functionality of "updateSelectInput()" within java script in the ui?
Yes, there is a way. Use the JavaScript function Shiny.onInputChange.
// change the value of an input
document.getElementById("id").value = "value";
// report the change to shiny
Shiny.onInputChange("id", "value");

Inserting objects into database from Flex app not working

I am trying to make a mobile app that inserts information into a database and while I have it pulling information and I have created my services, when I use the standard create service that Flash Builder 4.6 automatically makes, it just does not insert anything at all into the database.
I have tried everything and I am now with the following code:
I first create a variable array with the values of the service call
....
protected var Coordinatelist2:Coordinatelist = new Coordinatelist();
I then created a function to fill in the information. The variables SesID, Lat and Long are declared when my button is pressed.
....
protected function createCoordinatelist(item:Coordinatelist):void
{
Coordinatelist2.SessionID = SesID;
Coordinatelist2.Latitude = Lat;
Coordinatelist2.Longitude = Long;
createCoordinatelistResult.token = coordinatelistService.createCoordinatelist(Coordinatelist2);
}
After this, I then go and add the following line of code to the end of my button function.
.....
createCoordinatelist(Coordinatelist2);
Now, as far as I am concerned, this should then be writing to the database the items of SesID, Lat and Long using the created service token, but when I do this, nothing has entered into the database at all.
Am I doing something wrong here?
Sorry for the confusion but I came right.
What I found I had not done was commit my token once I created it. I simply used createCoordinatelistResult.token = coordinatelistService.commit(); and it worked perfectly.
Thanks for the feedback

Flex 3: getting .length of custom component id within a repeater... works sometimes, but not all the time

I have a repeater that populates a component, called 'project'. The project components are given an ID of 'wholeProject'. In all of my functions up until now, I was able to determine how many project components were made by doing the following:
wholeProject.length;
I used this in for loops, for each loops, and for changing the item settings within a project, i.e. something like this:
wholeProject[i].studentName = "Billy Bob";
However, I'm creating a new function that does not seem to like this wholeProject.length reference. I'm using it within the same level as all the others (i.e. the parent level). So far, my function is simply this:
public function getStudentYears():void
{
Alert.show(String(wholeProject.length));
}
when the application loads, the alert message simply does not appear. If I change the alert to something like this:
Alert.show("This is just a test.");
it works just fine. But for some reason, the wholeProject.length doesn't work in this function whereas it does in all my other ones. Anybody have any ideas as to why this is happening?
Use your repeater's data provider length instead.

Resources