2 Replies Latest reply on Nov 24, 2008 8:48 PM by narisras

    home page

    narisras
      Hi,
      am new for flex. i doing sign up screen for my web page.in the sign up screen the text input values after submit button clicks those values are stored in database values.after i have to show message registered successfully.in this process i done up to values storing the database using jsp. but the text input field values are not cleared. those values appearing as it is.i want clear that values and show the message "registered successfully".
      below am attaching my code please verify that one

      Attach Code

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="100%" height="100%"
      horizontalAlign="left"
      xmlns:flexlib=" http://code.google.com/p/flexlib/"
      xmlns:ct="com.edinc.edria.components.*" headerHeight="10" >

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;

      // Import necessary classes.
      import mx.controls.Alert;
      import mx.events.ValidationResultEvent;

      /* private var userData:Array=[ ]; */

      // Event listener for the valid and invalid events.
      /* private function handleValid(eventObj:ValidationResultEvent):void
      {
      if(eventObj.type==ValidationResultEvent.VALID)
      // Enable Submit button.
      registerLinkbutton.enabled = true;
      else
      registerLinkbutton.enabled = false;
      } */

      /* public var saveUser:ArrayCollection; */
      // Submit form is everything is valid.
      /* private function saveDetails():void
      {

      saveUser = new ArrayCollection(userData);
      Alert.show(uname.text);
      saveUser.addItem({Username:uname.text,MailId:signupmailid.text,Password:signpassword.text });
      } */
      /* private var validators:Array;
      private function intializeHandler(event:Event):void
      {
      validators=[emailvalidator,reqValid,reqValidpwd,stringvalidator];
      } */
      private function authenticate(event:MouseEvent):void
      {
      /* validations */
      /* reqValid.validate();
      emailvalidator.validate() */;

      /* var result:Array=Validator.validateAll(validators);
      if(result.length>0)
      {
      var messgae:String="the following fields are incorrect:\n";
      for(var i:uint=0;i<result.length;i++)
      {
      messgae+=result .target.source.id +"\n"
      }
      Alert.show(messgae);
      } */

      var pwd:String;
      var cpwd:String;
      pwd = signpassword.text;
      cpwd = conformpassword.text;

      if(pwd==cpwd)
      {

      /* sending data to database */
      addData.send(register);


      }
      else
      {
      Alert.show("Verify the password")
      }
      }
      ]]>
      </mx:Script>

      <mx:HTTPService id="addData" url=" http://dev.edinc.in:8080/poc/users/signup.jsp"/>
      <mx:Model id="register">
      <root>
      <uname>{uname.text}</uname>
      <signupmailid>{signupmailid.text}</signupmailid>
      <signpassword>{signpassword.text}</signpassword>
      </root>
      </mx:Model>

      <mx:Validator id="reqValid" required="true"
      source="{signupmailid}" property="text"

      requiredFieldError="Required:abc@xyz.com" />

      <mx:Validator id="reqValidpwd" required="true"
      source="{signpassword}" property="text"
      requiredFieldError="Required:Password" />

      <mx:EmailValidator id="emailvalidator" source="{signupmailid}" property="text"
      />

      <mx:StringValidator id="stringvalidator" source="{signpassword}" property="text"
      tooShortError="Password required minimum characters 4. "
      tooLongError="Password is longer than the maximum characters 20."
      minLength="4" maxLength="20"
      />

      <mx:VBox width="100%" height="100%" borderStyle="solid" >
      <mx:Form id="loginForm1" width="100%" height="100%" verticalGap="10">
      <mx:FormItem label="UserName">
      <flexlib:PromptingTextInput prompt="UserName" id="uname"/>
      </mx:FormItem>
      <mx:FormItem label="Email-Id:" id="Mail" required="true">
      <flexlib:PromptingTextInput prompt="Email-Id" id="signupmailid" />
      </mx:FormItem>
      <mx:FormItem label="Password:" id="Password" required="true">
      <flexlib:PromptingTextInput prompt="********" id="signpassword" displayAsPassword="true"/>
      </mx:FormItem>
      <mx:FormItem label="Confirm Password:" id="conformPassword" required="true">
      <flexlib:PromptingTextInput prompt="********" id="conformpassword" displayAsPassword="true"/>
      </mx:FormItem>
      <mx:FormItem horizontalAlign="center">
      <mx:Button id="registerLinkbutton" label="Submit" click="authenticate(event);" enabled="true" />
      </mx:FormItem>
      </mx:Form>
      </mx:VBox>
      </mx:Application>
        • 1. Re: home page
          rtalton Level 4
          You will need to reset your form fields manually by calling a function which sets each form field to a default value, and call this function after a successful registration. Flex is "stateful" and will not forget the values. You have to change them.
          • 2. Re: home page
            narisras Level 1
            thnx for reply to me.but user dont want click after submit button, reset button.after submiting the valuse the values are automatically cleard. how that one.i dont want to explicit reset button