CQ5 ExtJs widgets - extjs

I am new to Adobe CQ5 version 5.6.1 and trying to learn widget creation using ExtJs, so I am doing a few examples. All I am trying to do here is show an alert box on click of a button but not getting it. Here is the code.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
helpPath="en/cq/current/wcm/default_components.html#Title"
title="Title Component"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<webcastAtAGlanceTitle
jcr:primaryType="cq:Widget"
fieldLabel="Title"
maxLength="{Long}25"
name="./webcastAtAGlanceTitle"
xtype="textfield"/>
<selection
jcr:primaryType="cq:Widget"
defaultValue="pageProp"
fieldLabel="Configuration Options"
name="./selection"
type="radio"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<pageProp
jcr:primaryType="nt:unstructured"
text="Page Properties"
value="pageProp"/>
<RTE
jcr:primaryType="nt:unstructured"
text="RTE"
value="RTE"/>
</options>
</selection>
<testbutton
jcr:primaryType="cq:Widget"
autoWidth="{Boolean}true"
fieldLabel="test button"
text="Ok"
xtype="button">
<listener
jcr:primaryType="nt:unstructured"
click="function(){alert("Hello World","All set!!!");}"/>
</testbutton>
</items>
</jcr:root>
I am sure this is pretty simple to implement. Appreciate the inputs.
Thanks !

This doesn't need a listener at all. Alternatively, you can use the handler property to specify the function that needs to be called when the button is clicked.
<testbutton
jcr:primaryType="cq:Widget"
autoWidth="{Boolean}true"
fieldLabel="test button"
text="Ok"
xtype="button"
handler="function(b, e){alert('Hello!!');}" />
The b and e are the button and event objects respectively, that are passed to the handler. For further reference check this Button API.
And for the listener part, the node name has to be listeners instead of listener. That should work.
<testbutton
jcr:primaryType="cq:Widget"
autoWidth="{Boolean}true"
fieldLabel="test button"
text="Ok"
xtype="button">
<listeners
jcr:primaryType="nt:unstructured"
click="function(){alert("Hello World","All set!!!");}"/>
</testbutton>

Related

How to use TabbedPage in Xamarin WPF

I am trying to rebuild my old WinForms application using Xamarin Forms for more portability.
The application uses a TabControl, and the docs say that the closest Xamarin Forms element is the TabbedPage.
Here is the code:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyApp"
x:Class="MyApp.MainPage">
<TabbedPage.ToolbarItems>
<ToolbarItem Text="Settings"
Order="Primary"
Priority="0" />
<ToolbarItem Text="Tools"
Order="Primary"
Priority="1" />
<ToolbarItem Text="Help"
Order="Primary"
Priority="2" />
</TabbedPage.ToolbarItems>
<TabbedPage.Children>
<ContentPage Title="Main">
<Label Text="Coming soon!"/>
</ContentPage>
<ContentPage Title="Today">
<Label Text="Coming soon!"/>
</ContentPage>
<ContentPage Title="This week">
<Label Text="Coming soon!"/>
</ContentPage>
</TabbedPage.Children>
</TabbedPage>
It works well on my UWP build:
However, on my WPF build, it does not show the toolbar, making it impossible to switch tabs:
So what am I doing wrong here?
Thanks.
Update #1: I've tried to build the GTK target, it works correctly:
This screenshot is taken on Ubuntu. GTK# on Windows works the same way, but the drawing of the controls are too buggy.
After messing up with the element picker in the toolbar, I've finally found an answer:
There ARE buttons to switch between tabs in WPF. However, they are just invisible:
Setting the BarTextColor property in TabbedPage fixes the problem:
So the resulting code is:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:TimetableApp"
x:Class="TimetableApp.MainPage"
BarTextColor="Black">
<TabbedPage.ToolbarItems>
<ToolbarItem Text="Settings"
Order="Primary"
Priority="0" />
<ToolbarItem Text="Tools"
Order="Primary"
Priority="1" />
<ToolbarItem Text="Help"
Order="Primary"
Priority="2" />
</TabbedPage.ToolbarItems>
<TabbedPage.Children>
<ContentPage Title="Main">
<Label Text="Coming soon!"/>
</ContentPage>
<ContentPage Title="Today">
<Label Text="Coming soon!"/>
</ContentPage>
<ContentPage Title="This week">
<Label Text="Coming soon!"/>
</ContentPage>
</TabbedPage.Children>
</TabbedPage>

Word online SSO - getAccessTokenAsync no respons no error

I have created an Office add-in for Word Online but I can't get SSO working.
When the add-in is activated Word Online prompts the user for accepting the Add-in permissions, But I can’t get the SSO Token via Office.js.
When getAccessTokenAsync() first is called, I get no response or errors. If I call the function again I get error code 13008. Which indicate that the operation is running, but the result is never returned.
The manifest file is provided with
<WebApplicationInfo>
<Id>00e69b3f-c86c-4764-9e6e-xxxxxxxx</Id>
<Resource>api://localhost:43443/00e69b3f-c86c-4764-9e6e-xxxxxxxx </Resource>
<Scopes>
<Scope>openid</Scope>
<Scope>offline_access</Scope>
<Scope>user.read</Scope>
<Scope>profile</Scope>
</Scopes>
</WebApplicationInfo>
Azure Endpoint v2 registration
The add-in is registered at https://apps.dev.microsoft.com
Platform Web Api:
api://localhost:43443/00e69b3f-c86c-4764-9e6e-xxxxxxxx
Pre-authorized application:
bc59ab01-8403-45c6-8796-ac3ef710b3e3
57fb890c-0dab-4253-a5e0-7188c88b2bb4
d3590ed6-52b3-4102-aeff-aad2292ab01c
Permissions:
openid
offline_access
user.read
Profile
I have granted administrator consent using
https://login.microsoftonline.com/common/adminconsent?client_id=00e69b3f-c86c-4764-9e6e-xxxxxxxx&state=12345
Update:
If the same manifest is sideloaded into Powerpoint online or Excel/Spreadsheet online it can get the token by calling getAccessTokenAsync(), but still not in Word Online
Document Host
<Hosts>
<!--Each host can have a different set of commands. Cool huh!? -->
<!-- Workbook=Excel Document=Word Presentation=PowerPoint -->
<!-- Make sure the hosts you override match the hosts declared in the top section of the manifest -->
<Host xsi:type="Document">
<!-- Form factor. Currenly only DesktopFormFactor is supported. We will add TabletFormFactor and PhoneFormFactor in the future-->
<DesktopFormFactor>
<!--GetStarted information used on the callout that appears when installing the add-in.
Ensure you have build 16.0.6769 or above for GetStarted section to work-->
<GetStarted>
<!--Title of the Getting Started callout. resid points to a ShortString resource -->
<Title resid="dt.GetStarted.Title"/>
<!--Description of the Getting Started callout. resid points to a LongString resource -->
<Description resid="dt.GetStarted.Description"/>
<!--Not used right now but you need to provide a valid resource. We will add code in the future to consume this URL.
resid points to a Url resource -->
<LearnMoreUrl resid="dt.GetStarted.LearnMoreUrl"/>
</GetStarted>
<!--Function file is an html page that includes the javascript where functions for ExecuteAction will be called.
Think of the FunctionFile as the "code behind" ExecuteFunction-->
<FunctionFile resid="dt.FunctionFile.Url" />
<!--PrimaryCommandSurface==Main Office Ribbon-->
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<!--Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab -->
<!-- Documentation includes all the IDs currently tested to work -->
<CustomTab id="dt.Tab1">
<!--Group ID-->
<Group id="dt.Tab1.Group1">
<!--Label for your group. resid must point to a ShortString resource -->
<Label resid="dt.Tab1.GroupLabel" />
<Icon>
<!-- Sample Todo: Each size needs its own icon resource or it will look distorted when resized -->
<!--Icons. Required sizes 16,31,80, optional 20, 24, 40, 48, 64. Strongly recommended to provide all sizes for great UX -->
<!--Use PNG icons and remember that all URLs on the resources section must use HTTPS -->
<bt:Image size="16" resid="dt.TaskpaneButton.Icon" />
<bt:Image size="32" resid="dt.TaskpaneButton.Icon" />
<bt:Image size="80" resid="dt.TaskpaneButton.Icon" />
</Icon>
<!--Control. It can be of type "Button" or "Menu" -->
<Control xsi:type="Button" id="dt.LetterButton">
<!--Label for your button. resid must point to a ShortString resource -->
<Label resid="dt.LetterButton.Label" />
<Supertip>
<!--ToolTip title. resid must point to a ShortString resource -->
<Title resid="dt.LetterButton.Label" />
<!--ToolTip description. resid must point to a LongString resource -->
<Description resid="dt.LetterButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="dt.LetterButton.Icon16" />
<bt:Image size="32" resid="dt.LetterButton.Icon32" />
<bt:Image size="80" resid="dt.LetterButton.Icon80" />
</Icon>
<!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFuncion or ShowTaskpane-->
<!--Look at the FunctionFile.html page for reference on how to implement the function -->
<Action xsi:type="ExecuteFunction">
<!--Name of the function to call. This function needs to exist in the global DOM namespace of the function file-->
<FunctionName>ShowDialog</FunctionName>
</Action>
</Control>
<Control xsi:type="Button" id="dt.PhraseButton">
<!--Label for your button. resid must point to a ShortString resource -->
<Label resid="dt.PhraseButton.Label" />
<Supertip>
<!--ToolTip title. resid must point to a ShortString resource -->
<Title resid="dt.PhraseButton.Label" />
<!--ToolTip description. resid must point to a LongString resource -->
<Description resid="dt.PhraseButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="dt.PhraseButton.Icon16" />
<bt:Image size="32" resid="dt.PhraseButton.Icon32" />
<bt:Image size="80" resid="dt.PhraseButton.Icon80" />
</Icon>
<!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFuncion or ShowTaskpane-->
<!--Look at the FunctionFile.html page for reference on how to implement the function -->
<Action xsi:type="ExecuteFunction">
<!--Name of the function to call. This function needs to exist in the global DOM namespace of the function file-->
<FunctionName>ShowDialog</FunctionName>
</Action>
</Control>
</Group>
<Group id="dt.Tab1.Group2">
<!--Label for your group. resid must point to a ShortString resource -->
<Label resid="dt.Tab1.GroupLabel2" />
<Icon>
<!-- Sample Todo: Each size needs its own icon resource or it will look distorted when resized -->
<!--Icons. Required sizes 16,31,80, optional 20, 24, 40, 48, 64. Strongly recommended to provide all sizes for great UX -->
<!--Use PNG icons and remember that all URLs on the resources section must use HTTPS -->
<bt:Image size="16" resid="dt.TaskpaneButton.Icon" />
<bt:Image size="32" resid="dt.TaskpaneButton.Icon" />
<bt:Image size="80" resid="dt.TaskpaneButton.Icon" />
</Icon>
<Control xsi:type="Button" id="dt.SignonButton">
<!--Label for your button. resid must point to a ShortString resource -->
<Label resid="dt.SignonButton.Label" />
<Supertip>
<!--ToolTip title. resid must point to a ShortString resource -->
<Title resid="dt.SignonButton.Label" />
<!--ToolTip description. resid must point to a LongString resource -->
<Description resid="dt.SignonButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="dt.SignonButton.Icon16" />
<bt:Image size="32" resid="dt.SignonButton.Icon32" />
<bt:Image size="80" resid="dt.SignonButton.Icon80" />
</Icon>
<!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFuncion or ShowTaskpane-->
<!--Look at the FunctionFile.html page for reference on how to implement the function -->
<Action xsi:type="ExecuteFunction">
<!--Name of the function to call. This function needs to exist in the global DOM namespace of the function file-->
<FunctionName>OpenAccountStatus</FunctionName>
</Action>
</Control>
<Control xsi:type="Button" id="dt.SignonButton3">
<!--Label for your button. resid must point to a ShortString resource -->
<Label resid="dt.SignonButton.Label" />
<Supertip>
<!--ToolTip title. resid must point to a ShortString resource -->
<Title resid="dt.SignonButton.Label" />
<!--ToolTip description. resid must point to a LongString resource -->
<Description resid="dt.SignonButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="dt.SignonButton.Icon16" />
<bt:Image size="32" resid="dt.SignonButton.Icon32" />
<bt:Image size="80" resid="dt.SignonButton.Icon80" />
</Icon>
<!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFuncion or ShowTaskpane-->
<!--Look at the FunctionFile.html page for reference on how to implement the function -->
<Action xsi:type="ShowTaskpane">
<TaskpaneId>ButtonId1</TaskpaneId>
<!-- Provide a url resource id for the location that will be displayed on the task pane. -->
<SourceLocation resid="Contoso.Taskpane.Url" />
</Action>
</Control>
</Group>
<!-- Label of your tab -->
<!-- If validating with XSD it needs to be at the end, we might change this before release -->
<Label resid="dt.Tab1.TabLabel" />
</CustomTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>

ExtJs4 - Form defined in javascript multicombo loaded at runtime

When the form is initially loaded the multicombo on the form correctly reflects the data that is set up.
However, if I attempt to update the information at runtime, the list of options in the multicombo aren't updated when the form is displayed.
I have them successfully defined as form options, they have a simple 'text' only store. However, I can't seem to find the correct set of properties and method to actually update the multicombo from the C# code as needed.
I've noticed this as well. You can set the Ext.net.ListItems on page-load but they are fickle when it comes to setting them dynamically in code-behind. I now always use a Ext.net.Store with any Multicombo or ComboBox that needs to dynamically change.
You can use the Handler events on Focus or BeforeSelect to reload the list.
<ext:ComboBox ID="ComboBoxTransferGroupMembers" runat="server" FieldLabel="Transfer To" EmptyText="Group Members" LabelAlign="Top" DisplayField="Name" ValueField="Id" MarginSpec="0 0 5">
<Listeners>
<Focus Handler="#{ComboBoxTransferGroupMembers}.store.reload()" />
</Listeners>
<Store>
<ext:Store runat="server" OnReadData="StoreTransferGroupMember_ReadData" ID="StoreXferGroup">
<Model>
<ext:Model IDProperty="Id" runat="server">
<Fields>
<ext:ModelField Name="Name" />
<ext:ModelField Name="Id" />
</Fields>
</ext:Model>
</Model>
<Parameters>
<ext:StoreParameter Mode="Raw" Name="Group" Value="#{ComboBoxTransferGroup}.getValue()" />
</Parameters>
</ext:Store>
</Store>
<DirectEvents>
<Select OnEvent="ComboBoxTransferGroupMembers_Select">
<ExtraParams>
<ext:Parameter Mode="Raw" Name="Group" Value="#{ComboBoxTransferGroup}.getValue()" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:ComboBox>

Can't find an element on a webview page of an iOS native app using Appium

I have a native app which opens few web-view pages. I'm running appium on the app to do some automation test on a web-view page that I need to scroll down to find the username and password fields. I tried all the suggestion I can find online, and it doesn't work. Can anyone help?
I'm running:
Appium v1.3.5
iOS 8.1
Here is my code:
// switch to webview
Thread.sleep(6000);
final Set<String> contextNames = driver.getContextHandles();
for (final String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains("WEBVIEW")) {
driver.context(contextName);
}
}
Thread.sleep(6000);
WebElement x = driver.findElement(By.cssSelector("Username *"));
assertTrue(x.isDisplayed());
Here is the element I try to scroll to and enter username
<AppiumAUT>
<UIAApplication name="Demo A" label="Demo A" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0" x="0" y="24.125" width="375" height="642.1875">
<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/2" x="0" y="0.6875" width="375" height="665.625">
<UIAScrollView name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/2/1" x="29.296875" y="40.53125" width="316.40625" height="548.4375">
<UIAWebView name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/2/1/0" x="29.296875" y="40.53125" width="684.375" height="1170.703125">
<UIAStaticText name="Username *" label="Username *" value="" dom="[object Object]" enabled="true" valid="true" visible="false" hint="" path="/0/2/1/0/15" x="94.921875" y="783.5" width="92.578125" height="22.265625">
</UIAStaticText>
<UIATextField name="" label="" value="" dom="[object Object]" enabled="true" valid="true" visible="false" hint="" path="/0/2/1/0/16" x="94.921875" y="811.625" width="604.6875" height="46.875">
</UIATextField>
Here is the error message:
org.openqa.selenium.InvalidElementStateException: SyntaxError: DOM Exception 12 (WARNING: The server did not provide any stacktrace information)Command duration or timeout: 22 milliseconds
I have tried the following and doesn't work:
switch to the window first using driver.switchTo().window("WEBVIEW_1");
use driver.findElement(By.id("Username *"))
use driver.findElement(By
.xpath("//input[#name='Username *']"));
use driver.findElement(By .xpath("//UIAApplication[1]/UIAWindow[3]/UIAScrollView[1]/UIAWebView[1]/UIAStaticText[14]"));
I also tried to scroll to it first:
use just scollto: driver.scrollTo("Username *");
`((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", driver.findElement(By.name("Username *")));`
Error message are either NoSuchElement or the one above.
Please help! Thanks!
I'd go for driver.findElement(By.xpath("//UIAStaticText[contains(#name,'Username')]")); Actually, all search methods for element location can be tested in Appium Inspector first to see if they work.
if you test web app, you have to use web page locators. See my answers (corrected :) ) here: Unable to find an element in Browser of the Android emulator using Appium and C#

ExtJs Set Parameters Values

I have a form with some controls (extJs and ASP) like this:
<ext:ComboBox ID="Countries" runat="server" .../>
<asp:CheckBox ID="cb1" runat="server" />
I want to send parameters using BaseParams of the store object:
<ext:Parameter Name="cid" Value="Ext.get('#{Countries}').getValue()" />
<ext:Parameter Name="cbv" Value="#{cb1}.dom.checked" />
and that became:
Ext.apply( options.params,{
"cid":Ext.get('CountryCities1_Countries').getValue(),
"cbv":Ext.get("CountryCities1_cb1").dom.checked}
);
as you see get the value from ASP.Net checkbox is simpler than extJs Combobox... Do you know other clean way to get the combobox value?
I found it... Just like this:
<ext:ComboBox ...>
<Listeners>
<Select Handler=" #{myStore}.reload({ params: {cid: this.value}});" />
</Listeners>
</ext:ComboBox>

Resources