Add button for new page created by Link in Vaadin application - user-interface

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

Issues in trying to combine 'View' and 'Edit' in a single view in ASP.NET-MVC

I have an image gallery which has the following route:
// gallery id
routes.MapRoute(
"gallery-route",
"gallery/{galleryID}/{imageID}/{title}",
new { controller = "Gallery", action = "Index", galleryID = (string)null, imageID = (string) null, title = (string) null},
new { galleryID = #"\d+" }
);
I can have URLS like :
example.com/gallery/4/23 - shows
gallery 4 and image 23
example.com/gallery/4 - shows
gallery 4 and first image in that
gallery
I was trying to make an 'edit in place' mode which lets an administrator edit the images and running into several issues. Currently the editing functionality is non-AJAX.
1) How should i keep a 'sticky' edit mode parameter. There won't be an 'edit' button next to each image. i want the edit mode to be 'sticky', but then I'm finding I either need to set it in session or add a parameter to every single link on the page which is clumsy.
2) I have caching enabled for this view. Therefore if i make a change and refresh - the original cached view remains.
Can anyone give me any thoughts?
why not change the output on the view depending on the users authorisation status. Using inline code and Html helper functions in the ascx to either write out the values in HTML for readonly roles and for editor roles add a post form around input controls with the current values in. Then on the controller handle post in a separate procedure to save the edits.
or simply add an edit view ascx as well as a read view ascx.
Also when the post controller procedure fires replace the cache object with the new data recorded in the post.
finally of you have image caching problems when administering the gallery. Try adding a random string to the query eg:
function GetNewUrl(url)
{
Random rnd = new Random();
return url +"?"+rnd.Next(1000).ToString();
}
You need to flush the cache for the page when a change is made. Don't show the cached page or cache the page when the user is logged in as administrator, as they will have a different view with edit controls etc. For a sticky mode where an administrator can choose to be in edit mode throughout the site this would have to be stored in the session. I use something based on this for caching controller actions, with an additional method to determine whether to cache the output/use the cached output.

In IE 11, the “New Tab Page” is causing 404 error in web application

I have a asp.net mvc application. There is a search form and sometime users search with really long string. Since there is a limitation on the query parameter length I did the following.
I have made this form as POST method.
I have mentioned in the MVC controller to serve this page only for "POST" requests.
This is working perfectly in all the browsers. As usual IE is causing an issue in the following scenario :).
If users are using the search functionality more frequently, IE is adding the result page to the tile of the "New Tab" page under the frequent (Please refer to the Screen shot). Since the result page is POST only, whenever user clicks the tile, it is giving 404 error and users are annoyed about this.
Is there any meta tag or javascript to tell IE NOT to add this specific page to the favorite tile? Or add the home page to the tile instead of search page?
Note: I know if I allow GET request, 404 error will go away but I don't want to do that. Otherwise, I have to handle this and redirect the page.
Edit: I tried google but I couldn't find any useful information
Assuming this is your POST action:
[HttpPost]
public ActionResult Search(string p)
{
var results = SearchResults(p);
return View("Results", results);
}
You can add another action method using verb GET like this:
[HttpGet]
public ActionResult Search()
{
return View();
}
So this way, if users clicks on the tile they will be redirected to the Search page ready for start typing in your search form.

Netsuite: How to insert an iframe on post call

I have written a suitelet which has two parts - GET and POST.
In GET method I have a dropdown and a submit button.
In POST method, I have 5 text fields which display the data based on value fetched from dropdown in GET.
I want to call an iframe on submit button click. iframe will show POST method logic. In short, I don't want to navigate to new page on submit, but to make the whole thing work on a single page.
MY CODE
function init(request, response)
{
if(request.getMethod() == 'GET')
{
//... some code for dropdown and submit
//code for iframe
var context = nlapiGetContext();
var url = 'https://**url-of-post-method-results**.com';
var title = context.getSetting('SCRIPT', 'custscript_suitelet_title')
var content = '<iframe width=960px height=100% style="height:640px;" src=' + url + '></iframe>'
var newField = form.addField ('content', 'inlinehtml', title);
form.addField('extra', 'inlinehtml', '')
form.setTitle (title);
newField.setLayoutType('outsidebelow');
newField.setDefaultValue (content);
form.addSubmitButton('Submit');
response.writePage(form);
}
}
I referred to Marty Zigman's tutorial on embedding iframe. But I'. confused where to embed the iframe, in GET or POST?
To the best of my knowledge, NetSuite has no built in way via their API to avoid a page refresh in a case like this. Clicking the submit button, will by default, submit the form via a post method synchronously. You need to interrupt the click() event method via jQuery on NetSuite's default form submit button using client side code. You would then send the post yourself using jQuery, and on a response, show the information you would like, again via jQuery, by updating the iframe src url.
I apologize I do not have currently have access to an account to be able to give you the appropriate JavaScript. I would be cautious of breakage though since you will need to hack into the NetSuite UI a bit to make this work.

WP7 WebBrowser control headers

HI, is possible to add request headers in WP7 WebBrowser control?
There is no way to do this. If you need to change headers you'll need to use HttpWebRequest.
You could intercept the requests from the WebBrowser control and make them yourself via HWR but this could get complicated very quickly.
No - I don't think there's any API hook available for this.
It's a similar problem to the "change the user agent" request discussed in Bring back mobile version of website in WebBrowser control for wp7?
Sorry to necro but the answers here are wrong. Headers can be added to a WebBrowser through the Navigate method.
WebBrowser.Navigate(YourURI, null, YourCustomHeaderString)
See this page: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff626636(v=vs.105).aspx
.
These headers will only apply to the first page navigated to through your code. If you want the headers to stay the same even when users click a link inside the web browser control, add this for the WebBrowser's navigating event:
private void browser_Navigating(object sender, NavigatingEventArgs e)
{
string url = e.Uri.ToString();
if(!url.Contains("YESHEADERS"))
{
e.Cancel = true;
string newUrl;
if(url.Contains("?"))
{
newUrl = url + "&YESHEADERS";
}
else
{
newUrl = url + "?YESHEADERS";
}
browser.Navigate(newUrl, null, "fore:" + Variables.GetForeground() + "")
}
}
Here's what that does:
We create an indicator, YESHEADERS, that tells us whether or not we have added custom headers.
When the WebBrowser tries to Navigate, we check whether or not the URL it is navigating to, e.Uri, contains YESHEADERS.
If it does, we've already added our headers. Take no action
If it does not, cancel the current navigation. Create a new URL equal to the old URL plus our indicator. We add YESHEADERS on to the new URL in it's query string. If you are not familiar with query strings that is fine, just know that they are extra strings on the URL that have no effect in our case. About Query Strings
Then, we navigate to the new URL, and add our custom headers.
In short, if we have our indicator YESHEADERS the web browser knows that we've added our custom headers, if we don't have YESHEADERS, than the web browser needs to add the headers.

How do I get the silverlight view page name and querstring from silverlight code behind?

VS2010 w/Ria Services & SL4.
I already have my SL app loaded in the browser.
User clicks around to different view pages and I would like to store their current location in a list of "recently visited pages".
To do that, I need to store the view page + any existing querystring key/values.
Ex: here is a real page in my sl app:
http://localhost:52878/Default.aspx#/DocSearchShell?CM-Origination
I don't care about anything before the # sign - there are a million ways on google to get the http: // localhost:52878/Default.aspx uri from sl.
What I DO want is the "DocSearchShell?CM-Origination" portion of the querystring - that is what I want to capture and store for the "recently visited pages"
How do I do this from sl4 (.NET 4) code-behind?
Thanks!
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// The answer is this:
// e.Uri.OriginalString;
}
You can access the part of query string after "#" symbol via System.Windows.Browser.HtmlPage.Window.CurrentBookmark.
It works from any part of SL application.

Resources