Dear All/Robert Shilten
I want to pass one parameter from my custom mxml page to header widget of flex viewer.please help me in this matter,
Thanks to All.
Nadir,
Sure I have a couple of sites setup to use a login page that is part of the Viewers source code. You can find the code for this here http://gis.calhouncounty.org/devsummit2012/devsumit2012.zip It just sets up states on the main index.html page and the initial state is the login stuff and it will not switch states until login is successful. The ASP.net web service included also has the ability based on login to define which main config.xml the user is to receive.
Glad that the code worked for you. Now can you help me in return?
The addSharedData function in the BaseWidget is just a simple function that dispatches an AppEvent. You can do that in your custom mxml yourself.
var data:Object = { key: key, collection: arrayCollection }; AppEvent.dispatch(AppEvent.DATA_PUBLISH, data);
-----Sender Custom Page------------------
xmlns:fx="http://ns.adobe.com/mxml/2009" ibrary://ns.adobe.com/flex/spark"
library://ns.adobe.com/flex/mx"Login Page" minWidth="955" minHeight="600" backgroundColor="#8099B2">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="UserService" url="http://localhost/mySirensData/Default.aspx" fault="httpFaultHandlerData(event)" showBusyCursor="false" requestTimeout="300" result="DataHandler(event)" resultFormat="xml" method="post" />
</fx:Declarations>
<fx:Script>
import com.esri.viewer.AppEvent;
import com.esri.viewer.BaseWidget;
import com.esri.viewer.IBaseWidget;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.Operation;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.rpc.xml.SimpleXMLEncoder;
import mx.utils.ArrayUtil;
import mx.utils.StringUtil;
[Bindable]
private var RAc:ArrayCollection;
public var params:Object ={};
private function httpFaultHandlerData(event:FaultEvent):void
{"There was a problem in sending","Error " + event.message.toString());}
private function DataHandler(event:ResultEvent):void
{
var msArr:ArrayCollection = new ArrayCollection();
var transferData:Object = {message:"UserGroup",Value:RAc[0]["Countchk"]};
msArr.addItem(transferData);
//Not visible in my custom page method of basewidget class .addSharedData( );
}
private function convertXmlToArrayCollection(file:String):ArrayCollection
var xml:XMLDocument = new XMLDocument(file);
var decoder:SimpleXMLDecoder = new SimpleXMLDecoder();
var data:Object = decoder.decodeXML( xml );
var array:Array = ArrayUtil.toArray(data.parent.child);
return new ArrayCollection(array) ;
</fx:Script>
<mx:LinkButton id="NewUser" x="10" y="5" width="126" height="24" label="New User" color="#FF3322" fontFamily="New Times Roman" fontWeight="bold" fontSize="20" fontStyle="normal" visible="false" click="linkbutton1_clickHandler(event)"/>
<s:BorderContainer x="423" y="226" height="109" width="472" borderColor="#FFFFFF" backgroundColor="#8099B2" borderStyle="solid" borderWeight="2" >
<s:VGroup height="60" width="100%" >
<s:FormItem width="460" height="20" label="User Name: " textAlign="left" color="#000000">
<s:TextInput id="txtUser" width="100%" color="#00000"/>
</s:FormItem>
<s:FormItem width="460" height="12" label="Password: " textAlign="left" color="#000000">
<s:TextInput id="txtPass" top="0" width="100%" color="#00000" displayAsPassword="true"/>
</s:VGroup>
<s:HGroup x="0" y="75" width="100%" height="25" horizontalAlign="center" verticalAlign="justify" color="#00000">
<s:Button id="lblLogin" label="Login" x="100" click="lblLogin_clickHandler(event)"/>
<s:Button id="lblCancel" label="Cancel" x="100" />
</s:HGroup>
</s:BorderContainer>
</s:Application>
from remote service result received and this send to header widget.
----------Receiver Widget----------------------------------
xmlns:fx="http://ns.adobe.com/mxml/2009"
library://ns.adobe.com/flex/spark"
library://ns.adobe.com/flex/mx"
com.esri.viewer.*"
com.dougmccune.controls.*"
rtl"
100%" initialize="basewidget_initializeHandler(event)"
>
import com.esri.viewer.TransferDataManager;
import com.esri.viewer.ViewerContainer;
function basewidget1_creationCompleteHandler(event:FlexEvent):void
{// I want to get parameter value in this function
On this value I will decide show or hide the edit option for the user.
private function img_clickHandler(event:MouseEvent):void
if(event.currentTarget.id=="IdentifyBtn")
"Identify"));
else if(event.currentTarget.id=="layers")
"Layers"));
else if(event.currentTarget.id=="Edit")
var url:URLRequest = new URLRequest("EditPage.html");
var uv:URLVariables = new URLVariables();
"post";
"fred";
_blank");
else if(event.currentTarget.id=="drawingToolsBtn")
((Tools"));
<mx:Canvas id="myCanvas" x="0" y="0" width="100%" backgroundColor="0x8099B2" height="150" borderColor="#FFFFFF">
<mx:Image id="imgbg" x="0" y="0" width="100%" height="80%" layoutDirection="ltr" maintainAspectRatio="false" source="assets/images/headerLogo.png" />
<mx:Image id="layers" x="5" y="120" width="10%" height="20%" layoutDirection="rtl" toolTip="All Layers" source="assets/images/02_Header.png" click="img_clickHandler(event)" />
<mx:Image id="IdentifyBtn" x="100" y="120" width="15%" height="20%" layoutDirection="rtl" toolTip="Identify" source="assets/images/i_info.png" click="img_clickHandler(event)" />
<mx:Image id="SearchButtonByRegion" x="200" y="122" width="10%" height="20%" layoutDirection="rtl" toolTip="Search By Region" source="assets/img/11.png" click="img_clickHandler(event)" />
<mx:Image id="SearchButtonByCity" x="290" y="122" width="10%" height="20%" layoutDirection="rtl" toolTip="Search By City" source="assets/img/12.png" click="img_clickHandler(event)" />
<mx:Image id="Edit" x="400" y="122" width="10%" height="20%" layoutDirection="rtl" toolTip="Edit" source="assets/images/i_draw.png" click="img_clickHandler(event)" />
<mx:Canvas>
please read the creation complete handler.i want to get value from custom page here and on this value I will decide to show/hide edit option to the user.
Thanks in advance.
Dear Robert
I have my custom mxml page.this page receive some parameter from database.from these parameter I decide current user.where this user is from admin group or normal group.from the value of the database I send one value to header widget as according to the user group and visible and hide some options for the user.please help to sove this.i already use single ton pattern.but so for no success.Always get null value in header widget.
\thanks in advance
You would use widget communication. Widget Communication Explained You will have to edit the Header Controller widget to listen for the data you are sending as well. If you provide more specifics than I can provide more detailed instructions.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.