Dynamically add a tab to actionscript TabBar - dynamic

I am trying to add a new tab to an actionscript TabBar control at runtime. When I use addChild() to add a tab to the tab bar I get an exception at runtime:
Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.
However, when I tried using addElement() instead I get an error at compile time:
1061: Call to a possibly undefined method addElement through a reference with static type spark.components:TabBar.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%"
height="100%">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
private var _lastAddedNumber:int = 1;
protected function btnAddNewTab_clickHandler(event:MouseEvent):void
{
tabby.dataProvider.addItem('New '+_lastAddedNumber);
_lastAddedNumber++;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:Button id="btnSave"
click="btnAddNewTab_clickHandler(event)"
label="Add New Tab"/>
<mx:Form top="50">
<mx:FormItem label="tabWidth:">
<s:HSlider id="slider"
minimum="40"
maximum="120"
value="100"/>
</mx:FormItem>
</mx:Form>
<s:TabBar id="tabby"
horizontalCenter="0"
verticalCenter="0">
<s:layout>
<s:HorizontalLayout gap="-1"
columnWidth="{slider.value}"
variableColumnWidth="false"/>
</s:layout>
<s:dataProvider>
<s:ArrayList source="[red,orange,yellow,green,blue]"/>
</s:dataProvider>
</s:TabBar></s:Application>
may this will help you!!!

Related

Unable to view screen shot in Extent Report

I am using POM with extent report and everything is working fine, also on clicking screen shot its opening in big size but as per the client requirement he need screen shot in bigger size without click on it. I got some suggestion from my senior he said like i need to remove the thumbnail so that it will appear in bigger size, no where i found this option.
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>dark</theme>
<!-- document encoding -->
<!-- defaults to UTF-8 -->
<encoding>UTF-8</encoding>
<!-- protocol for script and stylesheets -->
<!-- defaults to https -->
<protocol>https</protocol>
<!-- title of the document -->
<documentTitle>Dimension Data Automation Reports</documentTitle>
<!-- report name - displayed at top-nav -->
<reportName>Dimension Data - </reportName>
<!-- report headline - displayed at top-nav, after reportHeadline -->
<reportHeadline>Test Automation Report</reportHeadline>
<!-- global date format override -->
<!-- defaults to yyyy-MM-dd -->
<dateFormat>yyyy-MM-dd</dateFormat>
<!-- global time format override -->
<!-- defaults to HH:mm:ss -->
<timeFormat>HH:mm:ss</timeFormat>
<!-- custom javascript -->
<scripts>
<![CDATA[
$(document).ready(function() {
});
]]>
</scripts>
<!-- custom styles -->
<styles>
<![CDATA[
]]>
</styles>
</configuration>
</extentreports>
public class ExtentManager {
private static ExtentReports extent;
public static ExtentReports getInstance() {
if (extent == null) {
Date d = new Date();
//String fileName = d.toString().replace(":", "_").replace(" ", "_") + ".html";
String fileName="index"+".html";
String reportPath = Constants.REPORTS_PATH + fileName;
extent = new ExtentReports(reportPath, true, DisplayOrder.NEWEST_FIRST);
extent.loadConfig(new File(System.getProperty("user.dir") + "/config/ReportsConfig.xml"));
// optional
extent.addSystemInfo("Selenium Version", "2.53.0").addSystemInfo(
"Environment", Constants.ENV).addSystemInfo("Qa","Shiva");
}
return extent;
}
}
This can be done through javascript. Use the <scripts> tag to add the below script
$(document).ready(function() {
var imageElements = $('img.r-img');
for (var i=0; i<imageElements.length; i++) {
imageElements[i].setAttribute('style', 'width:25%;');
}
});
You can set the style for the screenshot (img elements) as per your need.

Android: data-binidng: disable click

I want to disable click when variable isAgree is false:
here code:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="handler"
type="myproject.ui.SubscribeBrandDialogFragment" />
</data>
<TextView
android:id="#+id/subscribeTextView"
android:layout_width="185dp"
android:layout_height="40dp"
android:layout_marginTop="#dimen/default_margin"
android:background="#{handler.isAgree ? #drawable/border_enable_bg : #drawable/border_disable_bg}"
android:gravity="center"
android:onClick="#{handler.isAgree ? handler.onClickSubscribe() : null}"
android:textColor="#{handler.isAgree ? #color/color_primary : #color/disable_text_color}" />
</layout>
But I get error in android:onClick :
e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Cannot find the setter for attribute 'android:onClick' with parameter type void on android.widget.TextView.
file:myproject\layout\subscribe_brand_dialog.xml
loc:100:31 - 100:81
****\ data binding error ****
at android.databinding.tool.processing.Scope.assertNoError(Scope.java:112)
at android.databinding.annotationprocessor.ProcessDataBinding.doProcess(ProcessDataBinding.java:101)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:65)
at org.jetbrains.kotlin.kapt3.ProcessorWrapper.process(annotationProcessing.kt:131)
I know that I can fix this by java code. But I want fix this ONLY in xml layout.
Use lambda expression.
android:onClick="#{() -> handler.isAgree ? handler.onClickSubscribe() : null}"
Well a couple things.
First, I would use the controls properties the way they are meant to be used. Setting null on the click handler does not appropriately handle the UI element, you are merely hacking.
You should be disabling the click property or focus property based on your boolean, rather then toggling click handlers to null.
Secondly typically when you are doing Terinaray statements in xml click events I have seen the handler::methodName used rather then handler.methodName to ensure it is handled property in the generated databinding classes for onClick.
Lastly, if you already have the agreed boolean, why not just handle the click in the code. You literally saved yourself 1 line for another line if you think about it.
myClick()
if(isAgree) . //you saved this
.
now you have to do this
ObservableBoolean<> myBool = new ObservableField()
myBool.set(true/false)
of you are adding the
#Bindable to a method.
Either way you are not really saving code by doing the boolean check in the xml and you lose your ability to unit test it or debug. Just my two cents.

Get select value in radio button group in xpages by SSJS

I have the following requirement in an xpages application:
I have a radio button group with two options.
I have a combobox whose values ​​will be calculated from the option chosen in the radio button group. The options will be calculated from the partial refresh of the combobox associated with the onChange event of the radio button.
My problem is that I could not get the value selected on the radio button to mount the combobox options. As I'm doing the assembly through SSJS I have to get the value selected on the radio button also in SSJS. Is there any component / method on xpages that I can get the selected value from?
I know that via RPC component or jquery coould get via CSJS the selected value, but I was only wanting to use SSJS.
Grateful
Knut,
I made an example based on your suggestion, according to the code below, but it did not work. Because?
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:radioGroup id="radioGroup2">
<xp:selectItem itemLabel="a"></xp:selectItem>
<xp:selectItem itemLabel="b"></xp:selectItem>
<xp:selectItem itemLabel="c"></xp:selectItem>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial" refreshId="computedField2" execMode="partial" execId="radioGroup2">
</xp:eventHandler></xp:radioGroup>
<xp:text
escape="true"
id="computedField2"
value="#{javascript:getComponent('radioGroup2').getValue()}">
</xp:text><xp:br></xp:br><xp:br></xp:br>
</xp:view>
Use
getComponent('radioGroup1').getValue()
Replace "radioGroup1" with your radio button group's id.
Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:radioGroup
id="radioGroup1"
value="#{viewScope.radio}">
<xp:selectItem itemLabel="a" />
<xp:selectItem itemLabel="b" />
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="checkBoxGroup1" execMode="partial" execId="radioGroup1">
</xp:eventHandler>
</xp:radioGroup>
<xp:br></xp:br>
<xp:checkBoxGroup
id="checkBoxGroup1"
value="#{viewScope.check}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
if (!getComponent('radioGroup1').getValue()) {
return [];
}
if (getComponent('radioGroup1').getValue() == 'a') {
return ['A1', 'A2'];
}
return ['B1', 'B2'];
}]]></xp:this.value>
</xp:selectItems>
</xp:checkBoxGroup>
</xp:view>
Instead of getComponent('radioGroup1').getValue()you could use viewScope.radio as radio's value gets stored in view scope variable in this example.
I've done similiar by either using a getComponent("RadioButtonGroup1").getValue() in the computed values for the combobox. Or you could use this:
this.getParent().getValue()
in the onChange to populate a scoped variable that you base your combobox with.

Layout trouble with CUBA screen designer

I am testing the Cuba-Platform and I have trouble understanding the layout options within the screen designer.
I am trying to spread tables and twincolumns evenly and aligned over the screen. (And add a label on top of each)
The simplest task of stretching the containers (vbox and hbox) is difficult.
When I set height/width to 100% the items within are evenly distributed within the space. When I now try to set the height of the table within the vbox to 100% (hoping it would stretch) it gets reset to 100px.
I also tried the grid component, but when I set it to 100% the columns are have all the same hight (no good for label)
Maybe my understanding (coming from xaml/c# and the ms-components) is completely wrong. Please tell me, how can I create a view and ensure:
that the components are at the same height (stretched if need be)
that the components are aligned
that the whole screen is filled
label label
table twincolum
okcancel
As requested a simple image - of what by now drives me crazy..
Id like to add some code I eventually came up with - Its not yet the ideal thing:
<layout>
<hbox id="hboxexpand"
expand="assignTwinCol"
height="100%"
spacing="true"
width="80%">
<table id="userTable"
height="100%"
**width="auto"**>
<columns>
<column id="value1"
caption="msg://1"/>
<column id="firstName"
description="msg://firstNameHeader"/>
<column id="lastName"
caption="msg://nameHeader"/>
<column id="active"
caption="msg://activeHeader"/>
</columns>
<rows datasource="userDs"/>
</table>
<twinColumn id="assignTwinCol"
addAllBtnEnabled="true"
height="100%"
optionsDatasource="myDs"/>
</hbox>
</layout>
Please note: When I use the designer the **** part width=auto will be reset to 200px every time! I can only change that in the xml designer
Table does not have full support of AUTO width because width of columns can be adjusted by content, so I would recommend using fixed or relative width for a table.
<layout>
<hbox expand="twinColumn"
height="100%"
spacing="true"
width="100%">
<table id="userTable"
height="100%"
width="400px">
<columns>
<column id="firstName"/>
<column id="lastName"/>
<column id="active"/>
</columns>
<rows datasource="usersDs"/>
</table>
<twinColumn id="twinColumn"
addAllBtnEnabled="true"
optionsDatasource="usersSelectDs"
height="100%"/>
</hbox>
</layout>
If you want to set headers for TwinColumn columns you can use unwrap methods and Vaadin API of TwinColSelect:
public class Screen extends AbstractWindow {
#Inject
private TwinColumn twinColumn;
#Inject
private Table<User> userTable;
#Override
public void init(Map<String, Object> params) {
super.init(params);
TwinColSelect colSelect = twinColumn.unwrap(TwinColSelect.class);
colSelect.setLeftColumnCaption("Header Left");
colSelect.setRightColumnCaption("Header Left");
Layout tableComposition = userTable.unwrapComposition(Layout.class);
tableComposition.setCaption("Table Header");
}
}
We need to align our headers of the Table and TwinColumn. Table caption does not have padding-bottom 0.3em that TwinColumn headers have. We can add padding using stylename for the table:
<table id="userTable"
height="100%"
width="400px"
stylename="padding">
<columns>
<column id="firstName"/>
<column id="lastName"/>
<column id="active"/>
</columns>
<rows datasource="usersDs"/>
</table>
Then we create theme extension using Studio and add CSS definition to halo-ext.scss file:
.v-caption.v-caption-padding {
padding-bottom: 0.3em;
}
Now restart the application and our headers are aligned!
CUBA Team are planning to add caption and leftColumnCaption/rightColumnCaption attributes for components in the next minor release and you will be able to assign them from XML/Screen Designer.
See also:
https://doc.cuba-platform.com/manual-6.2/webComponentsHelper.html
https://vaadin.com/api/com/vaadin/ui/TwinColSelect.html

Loading Components Dynamically in Flex 4

I have an application whereby I am creating tabs in a TabNavigator dynamically. As you can see as per my codes I am basically having 5 tabs with specific names. Now I also have 5 mxml components with the same names as the tabs (that is the names of the mxml components are same as the tabs, that is Tab1,Tab2 etc. The non-dynamic way would be to use myTab1:Tab1 = new Tab1();myTab1:Tab2 = new Tab2); etc. Thus I will have to do this for each tab which I don't want.
What I want to do is to load the mxml components in each tab while I am looping through the Array. Hope I am clear enough.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.containers.VBox;
import mx.controls.Label;
import mx.events.FlexEvent;
import spark.components.NavigatorContent;
protected function tabNavigator_creationCompleteHandler(event:FlexEvent):void
{
var superModules:Array =["Tab1","Tab2","Tab3","Tab4","Tab5"];
for each (var superModule in superModules)
{
var myNavigatorContent:NavigatorContent = new NavigatorContent();
myNavigatorContent.percentHeight = 100;
myNavigatorContent.percentWidth = 100;
myNavigatorContent.label = superModule;
myNavigatorContent.addChild(superModule as DisplayObject);
tabNavigator.addChild(myNavigatorContent);
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:TabNavigator id="tabNavigator" width="100%" height="100%" creationComplete="tabNavigator_creationCompleteHandler(event)">
</mx:TabNavigator>
</s:Application>
Can somebody help on achieving this.
Many thanks.
Yes you can do it.Please find my solution below.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.containers.VBox;
import mx.controls.Label;
import mx.core.IVisualElement;
import mx.core.UIComponent;
import mx.events.FlexEvent;
import spark.components.NavigatorContent;
/*The class "Tab1","Tab2" not compiled with the application
because the linker and the compiler do not add classes
that are not referenced in the code.
Even though you’ll never use the _dummyVarToAddTabToAppCompilation1
variable it is necessary to use that line to instruct the compiler
to include Tab1,Tab2 in the compilation.*/
private var _dummyVarToAddTabToAppCompilation1:Tab1;
private var _dummyVarToAddTabToAppCompilation2:Tab2;
protected function tabNavigator_creationCompleteHandler(event:FlexEvent):void
{
var superModules:Array =["Tab1","Tab2"];
for each (var superModule in superModules)
{
var myNavigatorContent:NavigatorContent = new NavigatorContent();
myNavigatorContent.percentHeight = 100;
myNavigatorContent.percentWidth = 100;
myNavigatorContent.label = superModule;
// Convert class name to Class object.
var cls:Class = getDefinitionByName(superModule) as Class;
// Create a new instance of the class.
var instance:UIComponent = new cls();
myNavigatorContent.addElement(instance);
tabNavigator.addChild(myNavigatorContent);
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:TabNavigator id="tabNavigator" width="100%" height="100%" creationComplete="tabNavigator_creationCompleteHandler(event)">
</mx:TabNavigator>