I have Vaadin app that provides some calculations.
As a result of these calculations, the application redirects me to the file system through Link-mechanism, so that I have new page with many new Links.
So the question is how to add to this page one button?
Initial link looks like:
public static Link linkToNewTab(String caption, String url) {
Link lnk = link(caption, url);
lnk.setTargetName("_blank");
return lnk;
}
Related
How can I redirect my user to next view after the functions are loaded? I have two pages Sync Page and Main Menu Page and four functions inside Sync Page that will be loaded upon loading of my page then after loading that four functions it should redirect my user to my main menu page.
The problem is upon loading my sync page it will initialize the four functions and my navigation function it will redirect to my Main Menu Page then it will redirect back to my Sync Page
Here is the code of my Sync Page
public SyncPageViewModel(string host, string database, string contactID)
{
InsertActivityData(host, database, contactID);
InsertCAFData(host, database, contactID);
InsertContactsData(host, database, contactID);
InsertActivityData(host, database, contactID);
OnSyncComplete();
}
Here is the code of my navigation
public void OnSyncComplete()
{
Application.Current.MainPage.Navigation.PopAsync();
Application.Current.MainPage.Navigation.PushAsync(new MainMenu(), true);
}
Application.Current.MainPage.Navigation.PushModalAsync(new MainMenu(), true);
instead of
Application.Current.MainPage.Navigation.PushAsync(new MainMenu(), true);
Here's the scenario: I invoke an action method which returns PartialViewresult via ajax. The result is loaded into another view. Then I Navigate to another page and after this if I press browser back button the previously loaded PartialViewResult appears naked. By naked I mean no container view and layout is loaded, just plain html elements are rendered. Like this:
Has anyone faced and tackled this problem?
EDIT: To provide a better understanding of the situation here's my action method:
public ActionResult Inbox(int pageNumber = 1, int pageSize = 10, string filter = null)
{
var inboxItems = GetInboxItems(filter);
PagedList<InboxItem> pagedList = inboxItems.ToPagedList(pageNumber, pageSize);
pagedList.DisplayPage(pageNumber);
InboxViewModel vm = new InboxViewModel(pagedList);
if (!Request.IsAjaxRequest())
return View(vm);
return PartialView(vm);
}
In the Inbox.cshtml file I load layout based on if the request is ajax request:
#model Dokcentra.Models.InboxViewModel
#if (!Request.IsAjaxRequest())
{
Layout = "~/Views/Shared/_Cabinet.cshtml";
}
I think the last piece of code is what causes this problem because the layout file _Cabinet.cshtml has all the html, css and js and when I press browser back button that layout file doesn't load.
After lots of digging and hair pulling I realized that this only happens in Chrome. I found out that I need to provide a different url from the full html document. So when sending a reuest through AJAX to this action method I just append any arbitrary query string value to "?Cabinet/Inbox", like this:
var url= "/Cabinet/Inbox?anythingYouWant"
I can't figure out how to programatically add a view into a layout or page.
I need to add views at runtime without using static xml declaration since i need to fetch them from an http requested object... . I didn't find useful informations in the docs.
Anyone knows how to do?
I think you meant to dynamically add some view / controls to the page rather than to navigate into another page.
If so, you just need to add some controls into one of the layouts in your page (only containers [=layouts] can have multiple children.
so, your code (viewmodel/page controller) would look something like:
var layout = page.getViewById("Mycontainer");
// create dynamic content
var label = new Label();
label.text = "dynamic";
// connect to live view
layout.addChild(label)
In addition to having a page included inside your app (normal); you download the xml, css, & js to another directory and then navigate to it by then doing something like page.navigate('downloaded/page-name');
you can also do
var factoryFunc = function () {
var label = new labelModule.Label();
label.text = "Hello, world!";
var page = new pagesModule.Page();
page.content = label;
return page;
};
topmost.navigate(factoryFunc);
https://docs.nativescript.org/navigation#navigate-with-factory-function
You should check out this thread on the {N} forum.
The question is about dynamically loading a page and module from a remote server. The (possible) solution is given in this thread.
In an Windows Phone 7 application I got a CurrentPage, which, on a special event does navigate to a new page using the NavigationService:
NavigationService.Navigate(new Uri("/NewPage.xaml", UriKind.Relative));
Now when the user clicks back on the NewPage I want the app to skip the CurrentPage and go directly to the MainPage of the app.
I tried to use NavigationService.RemoveBackEntry, but this removes the MainPage instead of the CurrentPage.
How do I navigate to a new page without putting the current on the back stack?
When navigating to the NewPage.xaml pass along a parameter so you know when to remove the previous page from the backstack.
You can do this as such:
When navigating from CurrentPage.xaml to NewPage.xaml pass along parameter
bool remove = true;
String removeParam = remove ? bool.TrueString : bool.FalseString;
NavigationService.Navigate(new Uri("/NewPage.xaml?removePrevious="+removeParam , UriKind.Relative));
In the OnNavigatedTo event of NewPage.xaml, check whether to remove the previous page or not.
bool remove = false;
if (NavigationContext.QueryString.ContainsKey("removePrevious"))
{
remove = ((string)NavigationContext.QueryString["removePrevious"]).Equals(bool.TrueString);
NavigationContext.QueryString.Remove("removePrevious");
}
if(remove)
{
NavigationService.RemoveBackEntry();
}
This way, you can decide on the CurrentPage.xaml if you want to remove it from the backstack.
Where do you have called "NavigationService.RemoveBackEntry()"?
I think you have to do it at the new page, not at the page you want to skip!
edit:
So to get a better picture: you are having mainpage -> 1rst sub Page (should be skipped at back navigation) -> 2nd sub page which is independed from 1rst sub page.
2 ideas:
1) Try to call "NavigationService.RemoveBackEntry()" in the OnNavigatedFrom-Event of the 1rst sub page
2) Check in the OnNavigatedTo-Event of the 1rst sub page if the NavigationMode (see event args) == Back and navigate back once more.
It sounds like your calling RemoveBackEntry to early (While you're still on CurrentPage.xaml). Thats why its removing MainPage.xaml. When you navigate to NewPage.xaml, in the OnNavigatedTo event call NavigationService.RemoveBackEntry and that should fix the problem.
I'm using apache wicket and I run into trouble regarding testing the AjaxEventBehavior for a Radio button. Actually I want to test the "onClick" event like in my case when I select/click a radio button from a RadioGroup a specif page is rendered.
Code snippet:
RadioGroup<Boolean> selectPageRadioGroup =
new RadioGroup<Boolean>("selectPageRadioGroup", new Model<Boolean>(Boolean.TRUE));
selectPageRadioGroup.setDefaultModel(new Model<Boolean>(Boolean.TRUE));
final Radio<Boolean> radioButton1 =
new Radio<Boolean>("radioButton1", new Model<Boolean>(Boolean.FALSE));
radioButton1.add(new AjaxEventBehavior("onclick") {
#Override
protected void onEvent(AjaxRequestTarget target) {
setResponsePage(MyWebPage.class);
}
});
selectPageRadioGroup.add(radioButton1);
Assuming you have already done
WicketTester tester = new WicketTester();
tester.startPage(PageContainingRadioButton.class);
or a similar startPanel (Wicket 1.4) or startComponent (Wicket 1.5), so that your test has rendered a page containing the button at a known path you should be able to make WicketTester simulate the ajax behavior by something like
tester.executeAjaxEvent("blabla:form:selectPageRadioGroup:radioButton1", "onclick");
(You'll need to adjust that path of course.)
and then check that it did the right thing with
tester.assertRenderedPage(MyWebPage.class);