I have an xml file which has employee details who have registered with the company. I am populating the xml using a local server. I have a login page and have a registration page. I have successfully populated my xml data into a datagrid and can not update or add new employee through text input field. Kindly help me with the required process to be followed to update my xml file in my hard drive.
<?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"
xmlns:registration="services.registration.*"
creationComplete="employeeService.send()" currentState="login"
minWidth.registration="955" minHeight.registration="600">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Style source="assgpart2.css"/>
<s:states>
<s:State name="registration"/>
<s:State name="login"/>
<s:State name="home"/>
</s:states>
<fx:Script>
<![CDATA[
import events.Task;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.events.ValidationResultEvent;
import mx.messaging.messages.ErrorMessage;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
private var indexCounter:Number = 0;
private function validateForm():void
{
var vreName:ValidationResultEvent= un.validate();
var vrepass:ValidationResultEvent= ps.validate();
var vrecnfpass:ValidationResultEvent= cp.validate();
var vrefName:ValidationResultEvent= fn.validate();
var vrelName:ValidationResultEvent= ln.validate();
var vreemail:ValidationResultEvent= em.validate();
var vredate:ValidationResultEvent= datevalid.validate();
if( vreName.type == ValidationResultEvent.VALID &&
vrepass.type == ValidationResultEvent.VALID &&
vrecnfpass.type == ValidationResultEvent.VALID &&
vrefName.type == ValidationResultEvent.VALID &&
vrelName.type == ValidationResultEvent.VALID &&
vreemail.type == ValidationResultEvent.VALID &&
vredate.type == ValidationResultEvent.VALID )
{
if((male.selected== '0') && (female.selected == '0'))
{
mx.controls.Alert.show("you forgot to enter your gender....!");
}
else
{
mx.controls.Alert.show("thank you for registaring with us....!!!");
}
}
else
{
mx.controls.Alert.show("enter valid details");
}
}
private function validatelogin(event:MouseEvent):void
{
// getemployeesResult.token = login.getemployees(urname.text, passwd.text);
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="employeeService"
url="C:\Users\rknikhil\Adobe Flash Builder 4.6\Assignment1\src\assests\registration.xml"
result="employeeService_resultHandler(event)" method.registration="post">
</s:HTTPService>
<mx:StringValidator id ="un" source =" {uname}" property = "text" />
<mx:StringValidator id ="ps" source =" {pswd}" property = "text" />
<mx:StringValidator id ="cp" source =" {cnfpass}" property = "text" />
<mx:StringValidator id ="fn" source =" {fname}" property = "text" />
<mx:StringValidator id ="ln" source =" {lname}" property = "text" />
<mx:StringValidator source =" {email2}"
property = "text"
minLength.registration="8"
tooShortError.registration="min of 8 length"
/>
<mx:EmailValidator id ="em" source= "{email2}"
property="text"
requiredFieldError.registration="have to contain ----@---.com" />
<mx:DateValidator id="datevalid"
source = "{datev}"
inputFormat.registration="MM-DD-YYYY"
property = "text"
requiredFieldError.registration= "enter in MM-DD-YYYY format" />
<s:RadioButtonGroup id="gender"/>
<s:CallResponder id="getemployeesResult"/>
<registration:Registration id="registration"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
showBusyCursor="true"/>
<s:CallResponder id="getemployeesResult2"/>
<s:CallResponder id="getemployeesResult3"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel id="login" includeIn="login " x="0" y="0" width="100%" height="100%"
backgroundAlpha="0.0" contentBackgroundAlpha="0.0" title="login"
backgroundAlpha.login="400">
<s:Label x="16" y="196" text="username"/>
<s:TextInput id="urname" x="87" y="186"/>
<s:Label x="12" y="239" text="password"/>
<s:TextInput id= "passwd" x="87" y="238"/>
<s:Button x="10" y="278" label="login" click="validatelogin(event)"/>
<s:Button x="568" y="278" label="register" click ="currentState='registration'"/>
<mx:DataGrid id="dataGrid" x="2" y="2"
creationComplete="dataGrid_creationCompleteHandler(event)"
dataProvider="{getemployeesResult.lastResult}" editable.login="true">
<mx:columns>
<mx:DataGridColumn dataField="username" headerText="username"/>
<mx:DataGridColumn dataField="email" headerText="email"/>
<mx:DataGridColumn dataField="firstname" headerText="firstname"/>
<mx:DataGridColumn dataField="lastname" headerText="lastname"/>
<mx:DataGridColumn dataField="dob" headerText="dob"/>
<mx:DataGridColumn dataField="gender" headerText="gender"/>
</mx:columns>
</mx:DataGrid>
<s:Label x="379" y="220" width="92" height="19"
text="{employeeService.lastResult.employees.employee.username}"/>
</s:Panel>
<s:VGroup includeIn="registration" y="15" width="50%" height="50%" horizontalCenter="221">
<s:HGroup width="300" height="30">
<s:FormItem label="username" required = "true">
<s:TextInput id="uname" height="21" color="#D42222"
text="{getemployeesResult.lastResult[0].username}"/>
</s:FormItem>
</s:HGroup>
<s:HGroup width="300" height="30">
<s:FormItem label="password" required = "true">
<s:TextInput id="pswd" width="150" color="#D42222"
text="{getemployeesResult.lastResult[0].password}"/>
</s:FormItem>
</s:HGroup>
<s:HGroup width="300" height="30">
<s:FormItem label="confirmpassword" required = "true" >
<s:TextInput id="cnfpass" width="150" color="#D42222"
text="{getemployeesResult.lastResult[0].confirmpassword}"/>
</s:FormItem>
</s:HGroup>
<s:HGroup width="300" height="30">
<s:FormItem label="email" required = "true" >
<s:TextInput id="email2" width="150" color="#D42222" text="{getemployeesResult.lastResult[0].email}" />
</s:FormItem>
</s:HGroup>
<s:HGroup width="300" height="30">
<s:FormItem label="first name" required = "true">
<s:TextInput id="fname" width="150" color="#D42222"
text="{getemployeesResult.lastResult[0].firstname}"/>
</s:FormItem>
</s:HGroup>
<s:HGroup width="300" height="30">
<s:FormItem label="last name" required = "true">
<s:TextInput id="lname" width="150" color="#D42222"
text="{getemployeesResult.lastResult[0].lastname}"/>
</s:FormItem>
</s:HGroup>
<s:HGroup width="300" height="30">
<s:FormItem label="date of birth" required = "true">
<s:HGroup>
<s:TextInput id="datev" width="150" color="#D42222"
text="{getemployeesResult.lastResult[0].dob}"/>
</s:HGroup>
</s:FormItem>
</s:HGroup>
<s:HGroup>
<s:Label id= "gen" backgroundColor="#A6A1A1" chromeColor="#131212" color="#FCFAF8"
paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5"
text="gender"/>
<s:RadioButton id="male" label="male" groupName="gender"/>
<s:RadioButton id="female" label="female" groupName="gender" />
</s:HGroup>
<s:Button id="submit1" label="Submit" />
<s:Button id="back" label="Back" click="currentState='login'"/>
</s:VGroup>
<s:Panel includeIn="home" x="4" y="2" width="100%" height="100%" fontFamily="Times New Roman"
fontSize="20" fontWeight="bold" title="welcome to the home page">
<s:BorderContainer x="0" y="0" width="100%" height="100%" fontFamily="Times New Roman"
fontSize="12">
<s:Form includeIn="home" x="404" y="25" width="100%" height="100%">
<s:FormItem label="name">
<s:BorderContainer width="200" height="27">
<s:RichText width="100%" height="100%" color="#020202" fontSize="16"
horizontalCenter="0" paddingBottom="5" paddingLeft="5"
paddingRight="5" paddingTop="5" text="{urname.text} "
verticalCenter="0"
styleName.home="assgpart2.as"/>
</s:BorderContainer>
</s:FormItem>
<s:FormItem label="comments">
<s:BorderContainer width="200" height="97">
<s:RichEditableText left="0" top="0" width="100%" height="100%" text=""/>
</s:BorderContainer>
</s:FormItem>
<s:Button label="confirm" cornerRadius="5"/>
</s:Form>
<s:Image includeIn="home" x="0" y="2" width="382" height="285" opaqueBackground="true"
smooth="true" source="images/Lighthouse.jpg"/>
</s:BorderContainer>
</s:Panel>
<mx:LinkButton x="70" y="250" label="forgot password ?" focusColor="#FD0101"
rollOverColor="#FCF8F8" textDecoration="underline"
x.login="85" y.login="311"/>
</s:Application>