How to display flex state elements? - flex3

I am tying to create a login form which returns if login was successful or not.
I created two states and added forms to them. But how to display them in mxml?
<mx:states>
<mx:State name="log">
<mx:AddChild>
//i add form here
</mx:AddChild>
</mx:State>
<mx:State name="notlog">
<mx:AddChild>
//i add other form here
</mx:AddChild>
</mx:State>
<mx:VBox width="100%" height="100%" styleName="dark">
</mx:VBox>
How to display state within above Vbox? If I try to place state within Vbox I get an error that state can't be placed there.

Try The following one code. you need little bit of modification in it..
<mx:states>
<mx:State name="log">
<mx:AddChild>
<mx:Label text="child 1 Selected" />
//Write down the Codde here for log
</mx:AddChild>
</mx:State>
<mx:State name="notlog">
<mx:AddChild>
<mx:Label text="child 2 Selected" />
//Write down the Codde here for notlog
</mx:AddChild>
</mx:State>
</mx:states>
<mx:VBox width="100%" height="70%" styleName="dark">
<mx:Button label="Child1" click="currentState = 'log';" />
<mx:Button label="Child2" click="currentState = 'notlog';" />
</mx:VBox>
For more information visit following link
Click to open link
Have a nice day...

Related

System should not refresh after clicking on already selected radio button

I have 2 radio buttons , i selected one to them , there is an ajax call when i select that , what i want that there should not be any ajax call when i click on the already selected radio button . How to implement this.
<label for="cooperativeAuthorisedRepresentativeType">#{msg['com.crimsonlogic.egov.rol.rnra.landsubdivision.applicantdetails.cooperative.cooperativeAuthorisedRepresentativeType']}</label>
<h:selectOneRadio id="applicantDetails_cooperative_cooperativeAuthorisedRepresentativeType" required="true"
value="#{landSubdivisionController.cooperativeDetails.repCode}" requiredMessage="#{cmn['rol.common.message.error.RADIO_REQUIRED']}" >
<f:selectItem itemLabel="#{msg['REPRWAND']}" itemValue="REPRWAND" />
<f:selectItem itemLabel="#{msg['REPFOR']}" itemValue="REPFOR" />
<f:validateRequired />
<a4j:ajax event="click" listener="#{landSubdivisionController.changeRepresentativeTypeForCooperative()}" render="cooperativeCitizenNationalId,cooperativeCitizenNationalIdForFranchisee,cooperativeCitizenSurname,cooperativeCitizenOtherNames,cooperativeCitizenDistrict,cooperativeCitizenSector,cooperativeCitizenCell,cooperativeCitizenVillage,cooperativeForeignerPassportNo,cooperativeForeignerSurname,cooperativeForeignerOtherNames,cooperativeForeignerCountry,cooperativeForeignerCity" />
</h:selectOneRadio>
<div class="col-md-4">
<h:message for="applicantDetails_cooperative_cooperativeAuthorisedRepresentativeType" styleClass="help-block"></h:message>
</div>
You should use change event instead of click event of javascript.
You can try writing like this:
<a4j:ajax event="change"

update rad ajax manager from codebehind

Hi can someone help me how to call (or refresh) below control from code behind?
Currently it is working when I click my btnUpdate button. Along with I want to refresh the same usercontrol when I press another button also (ex: btnrefresh).
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnUpdate">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
<ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default" />
<asp:Panel ID="Panel1" runat="server" Width="100%">
<uc:EmpEnrollment runat="server" ID="EmpEnrollment" />
</asp:Panel>
Just add another AjaxSetting for your btnrefresh in your AjaxSettings like below:
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnUpdate">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="btnrefresh">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>

show pdf file in a icefaces modalpopup

Is it possible to show a pdf file in modalpopup with icefaces. Tried this but does not seem to work. Am new to icefaces too.
<ice:panelPopup autoCentre="true" visible="#{popup.visible}" modal="true">
<f:facet name="header"/>
<f:facet name="body">
<OBJECT DATA="/ICEfacesDevelopersGuide.pdf" TYPE="application/pdf" WIDTH="100%" HEIGHT="100%" />
<ice:commandButton value="Close" action="#{popup.close}" />
</f:facet>
</ice:panelPopup>
I ended up doing it the old way opening it on a new window or tab using output link and target attribute.

Flex List Component with Checkbox

I am trying to add a checkbox to a List component in my application and everything works seeming well until I scroll through my data.
As I scroll vertically in my List, any checks I may have added start to get added to other items in my List, sometimes the original item I checked is not even checked anymore.
For example, my List height is enough to see 5 items, I check Item 1, scroll down and every 5th item starts to get checked.
It's really odd and I have not been able to figure out why it is doing this. I looked at some examples online, and I'm not doing anything any different as far as I can tell.
I ran some traces and the Checkbox datachange event fires as I scroll through my list, but again, I am not sure why.
Here is the mxml test page for my List.
Any help is appreciated, thanks.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Array id="arr">
<mx:Object label="One" />
<mx:Object label="Two" />
<mx:Object label="Three" />
<mx:Object label="Four" />
<mx:Object label="Five" />
<mx:Object label="Six" />
<mx:Object label="Seven" />
<mx:Object label="Eight"/>
<mx:Object label="Nine" />
<mx:Object label="Ten" />
<mx:Object label="Eleven" />
<mx:Object label="Twelve" />
</mx:Array>
<mx:List
id="addrList"
height="100"
width="100%" fontSize="10"
borderStyle="solid"
borderColor="#000000"
borderThickness="1"
dataProvider="{ arr }">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox
change="trace('change')"
dataChange="trace('dataChange')"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>
</mx:Application>
your putting an object to a list dataprovider, dataprovider supports text only
try this
<mx:Script>
<![CDATA[
[Bindable]
private var arr:Array = ["a","b","c","d","e","f","g"];
]]>
</mx:Script>
<mx:List
id="addrList"
height="100"
width="100%" fontSize="10"
borderStyle="solid"
borderColor="#000000"
borderThickness="1"
dataProvider="{ arr }">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox change="trace('change')"
dataChange="trace('dataChange')"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>

Creating a column of RadioButtons in Adobe Flex

I am having an un-predictable behavior of creating radio buttons in advancedDataGrid column using itemRenderer. Similar kind of problem has been reported at
Creating a column of RadioButtons in Adobe Flex. I tried to use the same procedure i.e. bind every radio button selectedValue and value attributes with the property specified in the property of the associated bean but still facing the problem.
The button change values! The selected
button becomes deselected, and
unselected ones become selected.
Here is the code of my advancedDataGrid:
<mx:AdvancedDataGrid id="adDataGrid_rptdata"
width="100%" height="100%"
dragEnabled="false" sortableColumns="false"
treeColumn="{action}"
liveScrolling="false"
displayItemsExpanded="true" >
<mx:dataProvider>
<mx:HierarchicalData source="{this.competenceCollection}" childrenField="competenceCriteria"/>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="" id="action" dataField="criteriaName" />
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period1" value="{data}" selected="{data.period1}" group="{data.radioBtnGrpArray[0]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Periode 2" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period2" value="{data}" selected="{data.period2}" group="{data.radioBtnGrpArray[1]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Periode 3" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period3" value="{data}" selected="{data.period3}" group="{data.radioBtnGrpArray[2]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
</mx:columns>
</mx:AdvancedDataGrid>
Any work around is highly appreciated in this regard!
The selected button becomes deselected, and unselected ones become selected.
Is this problem occurring only for those radio buttons whose selected state was manually changed by the user? In that case it is because flex resets its selected state based on the value mentioned in the declaration when a RadioButton is reused. So even if you select/deselect a ratio button in the Periode 1 column, flex resets it to {data.period1} when you scroll away and come back. Making the column editable to save the modifications back to the data provider might work. Try changing the column declaration to:
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200"
editable="true" rendererIsEditor="true" editorDataField="selected">
EDIT: Try this - attempting to change the data provider when the radio button is selected. code written from memory and not tested - might contain bugs.
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%"
verticalAlign="middle">
<mx:RadioButton id="rb" name="period1" value="{data}"
selected="{data.period1}"
group="{data.radioBtnGrpArray[0]}" visible="{data.showRadioButton}"
change="outerDocument.handleRadio1(this);"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
//in a script tag outside the datagrid.
public function handleRadio1(renderer:IListItemRenderer):void
{
var index:Number = adDataGrid_rptdata.itemRendererToIndex(renderer);
this.competenceCollection[i].period1 = renderer.rb.selected;
}