Handling Dialogs in WPF with MVVM

I suggest forgoing the 1990’s modal dialogs and instead implementing a control as an overlay (canvas+absolute positioning) with visibility tied to a boolean back in the VM. Closer to an ajax type control. This is very useful: <BooleanToVisibilityConverter x:Key=”booltoVis” /> as in: <my:ErrorControl Visibility=”{Binding Path=ThereWasAnError, Mode=TwoWay, Converter={StaticResource booltoVis}, UpdateSourceTrigger=PropertyChanged}”/> Here’s how I have one implemented … Read more

Keep p:dialog open when a validation error occurs after submit

The onsuccess runs if ajax request itself was successful (i.e. there’s no network error, uncaught exception, etc), not if action method was successfully invoked. Given a <p:dialog widgetVar=”yourWidgetVarName”>, you could remove the onsuccess and replace it by PrimeFaces RequestContext#execute() inside saveMethod(): if (success) { RequestContext.getCurrentInstance().execute(“PF(‘yourWidgetVarName’).hide()”); } Note: PF() was introduced in PrimeFaces 4.0. In older … Read more

How to change theme for AlertDialog

In Dialog.java (Android src) a ContextThemeWrapper is used. So you could copy the idea and do something like: AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom)); And then style it like you want: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”AlertDialogCustom” parent=”@android:style/Theme.Dialog”> <item name=”android:textColor”>#00FF00</item> <item name=”android:typeface”>monospace</item> <item name=”android:textSize”>10sp</item> </style> </resources>

Access to file download dialog in Firefox

I have a solution for this issue, check the code: FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(“browser.download.folderList”,2); firefoxProfile.setPreference(“browser.download.manager.showWhenStarting”,false); firefoxProfile.setPreference(“browser.download.dir”,”c:\\downloads”); firefoxProfile.setPreference(“browser.helperApps.neverAsk.saveToDisk”,”text/csv”); WebDriver driver = new FirefoxDriver(firefoxProfile);//new RemoteWebDriver(new URL(“http://localhost:4444/wd/hub”), capability); driver.navigate().to(“http://www.myfile.com/hey.csv”);

How to prevent a dialog from closing when a button is clicked

EDIT: This only works on API 8+ as noted by some of the comments. This is a late answer, but you can add an onShowListener to the AlertDialog where you can then override the onClickListener of the button. final AlertDialog dialog = new AlertDialog.Builder(context) .setView(v) .setTitle(R.string.my_title) .setPositiveButton(android.R.string.ok, null) //Set to null. We override the onclick … Read more

Create and save a file with JavaScript [duplicate]

A very minor improvement of the code by Awesomeness01 (no need for anchor tag) with addition as suggested by trueimage (support for IE): // Function to download data to a file function download(data, filename, type) { var file = new Blob([data], {type: type}); if (window.navigator.msSaveOrOpenBlob) // IE10+ window.navigator.msSaveOrOpenBlob(file, filename); else { // Others var a … Read more

Select Directory error … delphi 7 [closed]

var olddir: string; //global variable procedure olddiris(name:string); begin if name=”trick” then olddir:= ‘c:\program files\’+name; end; procedure MyGetPath(name:string); var options : TSelectDirOpts; begin OldDirIs(name); //returns olddir if FileCtrl.SelectDirectory(OldDir,options,0) then ShowMessage(‘i got it’); end; procedure TForm1.Button1Click(Sender: TObject); begin Mygetpath(‘trick’); end; This code runs without error… (Note: changed GetPath -> MyGetPath; added “\” to ‘c:\program files’) If the … Read more