I wanted to enable custom shortcuts in my Firefox extension. The idea is that the user just focuses on a textbox, presses key combination, and it's shown in the textbox and saved to a preference. However, I couldn't get it to work. With this XUL
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/pref/pref.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://nextplease/locale/nextplease.dtd">
<prefwindow id="nextpleaseprefs" title="&options.title;" buttons="accept, cancel"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="nextplease.general" label="&options.general.title;" image="chrome://nextplease/skin/Sound Mixer.png">
<preferences>
<preference id="nextkey" name="nextplease.nextkey" type="int"/>
</preferences>
<vbox flex="1">
<hbox align="center">
<label value="&options.general.nextKey;" />
<textbox id="nextkey" flex="1" editable="false"
onkeyup="return nextplease.handleKeySelection(this, event);"
preference-editable="true" preference="nextkey"
onsynctopreference="alert('syncing'); return nextplease.syncKeySelector(this);"/>
</hbox>
</vbox>
</prefpane>
<script type="application/x-javascript" src="chrome://nextplease/content/nextpleaseCommon.js" />
<script type="application/x-javascript" src="chrome://nextplease/content/nextpleaseOptions.js" />
</prefwindow>
the event in onkeyup works. But when I click the OK button, I don't see a "syncing" alert. Why isn't onsynctopreference working? Is it impossible to have custom onsynctopreference attribute for a textbox?
It seems the problem was simply that preferences are only synchronized on input event (and maybe some others), but not on keyup.
Related
Trying to build a content Page with a WebView, DatePicker and button on the same content page. Any time I make the WebView Visible all the other controls become invisible. Have tried many variations but found this layout while googling. Worked for the author but not for me!
Not a lot of info out there on this. Would prefer to use a httpClient but the server I'm hitting requires JavaScript to be enabled. That causes a few issues!
Have tried numerous variations with no luck!
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
xmlns:dxco="clr-namespace:DevExpress.Maui.Controls;assembly=DevExpress.Maui.Controls"
xmlns:dxcv="clr-namespace:DevExpress.Maui.CollectionView; assembly=DevExpress.Maui.CollectionView"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:models="clr-namespace:Pcal.Models"
x:Class="Pcal.Views.GetCal"
Title="GetCal">
<VerticalStackLayout Spacing="40" Padding="10" Background="white">
<VerticalStackLayout Spacing="10" >
<dxe:DateEdit x:Name="CalMonth"
PickerActiveViewType="Month"
BackgroundColor="white"
LabelText="Select Month"
LabelFontSize="18"
IsLabelFloating="False"
IsDateIconVisible="True"
ClearIconVisibility="Auto"
Margin="10"
DisplayFormat="MMMyy" UseNativePicker="true"/>
<HorizontalStackLayout HorizontalOptions="Center">
<Button Text="Get Calendar" WidthRequest="380"
HorizontalOptions="Fill"
Clicked="OnClicked"
BackgroundColor="Purple"
TextColor="White"/>
</HorizontalStackLayout>
</VerticalStackLayout>
<WebView Source="https://pilot.fedex.com"
IsVisible="true"
x:Name="PFCWV1"
HorizontalOptions="EndAndExpand"
HeightRequest="320"
WidthRequest="380"
Navigating="WebViewNavigating"/>
</VerticalStackLayout>
</ContentPage>
I need to do a simple task but it looks like very heavy for me, i need to create XULRUNNER system which opens WWW.test.com in default window without address bar or any menu and nothing more, here are my codes but it doesn't seem to be working, can anybody help?
main.js
function url() {
windowObjectReference = window.open("http://www.test.com/", "test_WindowName", strWindowFeatures);
}
main.xul
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="500" height="500" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://myapp/content/main.js"/>
</window>
pref.js
pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");
pref("toolkit.defaultChromeFeatures", "chrome,dialog=no,all");
pref("toolkit.singletonWindowType", "xulmine");
/* debugging prefs, disable these before you deploy your application! */
pref("browser.dom.window.dump.enabled", true);
pref("javascript.options.showInConsole", true);
pref("javascript.options.strict", true);
pref("nglayout.debug.disable_xul_cache", true);
pref("nglayout.debug.disable_xul_fastload", true);
Just use the <browser> element
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="500" height="500" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://myapp/content/main.js"/>
<vbox id="browerbox" flex="1">
<browser flex="1" id="testbrowser" src="http://www.test.com/ />
</vbox>
</window>
The browser is very powerful element I would read up on all Attributes, Properties and Methods that you can use with it, https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser. What I gave you above will work but depending on what you ultimately need to do, you may need make a few changes.
I'm using primefaces 3.5 with JSF mojarra 2.2.
I've a page with two ui:include which are wrapped in a p:dialog and ui:param is being used to pass values in/out of the includes.
<p:dialog header="Customer Selection Criteria" widgetVar="customerSelectionDialog" width="1200" position="center" appendToBody="true">
<h:form id="customerForm">
<p:outputPanel id="customerSelection">
<ui:include src="../INTERNAL/8500.xhtml">
<ui:param name="showCidSelect" value="1" />
<ui:param name="targetObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
</ui:include>
<p:commandButton rendered="false" value="#{COMMON.COMMON_SELECTBUTTON}" action="#{customerDetailsInquiry.tchelp.handleReturnFromCustomerSelectionCriteria}" oncomplete="customerSelectionDialog.hide();" update=":mainForm:cf8444icg1014c1002" >
<f:setPropertyActionListener value="#{customerSearchEngine}" target="#{flash.customerSearchEngine}"/>
</p:commandButton>
</p:outputPanel>
</h:form>
</p:dialog>
<p:dialog closeOnEscape="true" modal="true" appendToBody="false" header="Entity Stack" widgetVar="entityStackDialog" width="400" >
<h:form id="entityForm">
<ui:include src="../INTERNAL/StackedEntity.xhtml">
<ui:param name="displayCaption" value="CID Numbers" />
<ui:param name="department" value="8" />
<ui:param name="stackedObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
</ui:include>
</h:form>
</p:dialog>
Backing Bean:
FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
String paramValue = (String) faceletContext.getAttribute("showCidSelect");
now the problem is with "showCidSelect" parameter.
showCidSelect determines whether to show "select" button in 8500.xhtml or not.
Since "showCidSelect" in this above example is set to "1", select button should be rendered.
Without the second dialog for "StackedEntity.xhtml" this works perfectly fine.
But when i put second dialog and its ui:param's this stops working and FaceletContext getAttribute call returns null.
As of now i'm forced to include "showCidSelect" in both dialogs, then everything works fine. But i somehow feel there is some other better possible solution for this problem.
Request expert help
It actually solved the same problem here by rewriting ui:include and ui:param to a custom JSF tag in a taglib.
Then you have a nice and easy to reuse tag, like:
<widgets:showCustomerSelector targetObject="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
And:
<widgets:stackedEntity displayCaption="CID Numbers" department="8" stackedObject="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
And then add new namespace to each JSF page/template where you use it (of, course):
xmlns:widgets="http://your-company/jsf/widgets/customer"
And write a taglib:
WEB-INF/widgets.jsf.taglib.xml:
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
<namespace>http://your-company/jsf/widgets/customer</namespace>
<tag>
<tag-name>showCustomerSelector</tag-name>
<description>#TODO Document this. Here goes your 8500.xhtml You had it in INTERNAL, better put templates in e.g. WEB-INF/templates/group/sub-group/ to have it out of document-root.</description>
<source>resources/tags/show_customer_selector.xhtml</source>
<attribute>
<name>targetObject</name>
<description>#TODO Document this.</description>
<required>true</required>
<!-- #TODO Find a **WAY** better type-hint, like an interface? -->
<type>java.lang.Object</type>
</attribute>
<attribute>
<name>rendered</name>
<description>Whether this tag is being rendered by JSF engine. </description>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
</tag>
<tag>
<tag-name>stackedEntity</tag-name>
<description>#TODO Document this. Here goes your StackedEntity.xhtml - keep file names lower_under_scored to avoid case-sensitive problems!</description>
<source>resources/tags/stacked_entity.xhtml</source>
<attribute>
<name>displayCaption</name>
<description>#TODO Document this.</description>
<required>true</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>department</name>
<description>#TODO Document this.</description>
<required>true</required>
<type>java.lang.Number</type>
</attribute>
<attribute>
<name>rendered</name>
<description>Whether this tag is being rendered by JSF engine. </description>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<name>stackedObject</name>
<description>#TODO Document this.</description>
<required>true</required>
<!-- #TODO Find a **WAY** better type-hint, like an interface? -->
<type>java.lang.Object</type>
</attribute>
</tag>
</facelet-taglib>
And finally, register it in web.xml:
<context-param>
<description>JSF widget tags library</description>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/widgets.jsf.taglib.xml</param-value>
</context-param>
In case user downloads particular type of file (let's say .doc), I should show one more item (i.e. possible action) in addition to Save and Open at unknownContentType Firefox dialog.
How can I do it?
Upd. Looking at FlashGot addon sources, I've extracted the following:
chrome.manifest
overlay chrome://mozapps/content/downloads/unknownContentType.xul chrome://flashgot/content/DMOverlayFx.xul
overlay chrome://global/content/nsHelperAppDlg.xul chrome://flashgot/content/DMOverlayMoz.xul
Why do they have two overlays? What second does? And, how to understand that user chosen my option?
DMOverlayFx.xul
<?xml version="1.0" encoding="UTF-8"?>
<overlay id="DMOverlayFF"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="Common.js"/>
<script type="application/x-javascript" src="DMOverlay.js"/>
<radiogroup id="mode" >
<vbox insertbefore="save" id="synoextcontainer" flex="1">
<hbox flex="1">
<radio id="synoext-dmradio" label="Download with Synology NAS" />
</hbox>
</vbox>
</radiogroup>
</overlay>
DMOverlayMoz.xul
<?xml version="1.0" encoding="UTF-8"?>
<overlay id="DMOverlayMoz"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="Common.js"/>
<script type="application/x-javascript" src="DMOverlay.js"/>
<radiogroup id="mode" >
<hbox position="3" >
<radio id="synoext-dmradio" label="Download with Synology NAS"/>
</hbox>
</radiogroup>
</overlay>
The important file to overlay is unknownContentType.xul. You can see an example here: http://code.google.com/p/firedownload/source/browse/chrome/content/unknownContentType-overlay.xul. This adds a new checkbox to the dialog, but you can use the same approach to add a new radio button. You'll want to include a new JS file in the overlay (like unknownContentType-overlay.js in this example) where you can override the standard processing of the radio buttons. Process your new option and hand off the other options to the existing implementation (look at helperApps.js to see how the standard processing works).
I would like, that if the user says "help" that the following field doesn't get filled, and that the user gets all possible options.
<form id="test">
<field name="var1">
<prompt bargein="true" bargeintype="hotword" >say xy </prompt>
<grammar src = "grammar.grxml" type="application/srgs+xml" />
<filled>
<assign name="myProdukt" expr="var1" />
you said <value expr="myProdukt"/>
</filled>
</field>
(let's say in the external grammar is "p1", "p2" and "p3", the user says "help", and the systems says "p1","p2","p3" and the user can choose again - therefore the word "help" has to be in the external grammar as well, doesn't it?)
thanks in advance
Yes, the active grammar must contain a "help" utterance which returns the value 'help'. You then catch the event with a help tag:
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml" version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd">
<form id="test">
<field name="var1">
<prompt bargein="true" bargeintype="hotword" >say xy </prompt>
<grammar src = "grammar.grxml" type="application/srgs+xml" />
<filled>
<assign name="myProdukt" expr="var1" />
you said <value expr="myProdukt"/>
</filled>
<help>
To choose a product, say,
<!-- whatever the product choices are -->
frobinator, submarine, curling iron, ..
<reprompt/>
</help>
</field>
</form>
</vxml>
Alternatively, following the DRY principle, this effect can be done globally for your application with using an application root document containing a link element. In the example app-root.vxml document below, there is a linkbinding a global grammar "help" utterance to the help event :
<?xml version="1.0"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
<link event="help">
<grammar mode="voice" root="root_rule" tag-format="semantics/1.0"
type="application/srgs+xml" version="1.0" xml:lang="en-US">
<rule id="root_rule" scope="public">
<one-of>
<item weight="1.0">
help
</item>
</one-of>
</rule>
</grammar>
</link>
</vxml>
This grammar will be active everywhere -- effectively merged with each active field grammar. If you need more information about application root documents, the section of the VoiceXML specification Executing a Multi-Document Application explains. Also see Handling Events from the Tellme Studio documentation
Then, in pages of your application, make reference to the application root document via the application attribute of the vxml element and speak appropriately in a help catch block:
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml" version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd"
application="app-root.vxml">
<form id="test">
<field name="var1">
<prompt bargein="true" bargeintype="hotword" >say xy </prompt>
<grammar src = "grammar.grxml" type="application/srgs+xml" />
<filled>
<assign name="myProdukt" expr="var1" />
you said <value expr="myProdukt"/>
</filled>
<help>
To choose a product, say,
<!-- whatever the product choices are -->
frobinator, submarine, curling iron, ..
<reprompt/>
</help>
</field>
</form>
</vxml>
You could, of course, put the link code in the same page as your form, but it is likely you will want help active for every field of your application unless there is collision with something in a particular field's grammar.