Textinput component questions

Hi All,
I have an issue passing number data to textinput component.
If my data have decimals like 8.45463 and I display the number with 2 decimal places like 8.45.
If user doesn't modify the number when I save again in the database is only 8.45.
It is a way to set the textInput component with value = 8.45463 and text = 8.45? I am sure with so many financial applications it should be something up there.
I have the same issue with advance datagrid displaing numbers.
Any ideas or comments?
Thanks
JFB

Done,
Thanks for everyone reply and help.
If someone wants to use this component or make it better.
Best,
JFB
<?xml version="1.0" encoding="utf-8"?>
<mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml" textAlign="right" creationComplete="init()" >
    <mx:Script>
        <![CDATA[
            import mx.formatters.NumberFormatter;
            import mx.controls.listClasses.*;
            private var _realValue:String;
            private const POSITIVE_COLOR:uint = 0x000000; // Black
            private const NEGATIVE_COLOR:uint = 0xFF0000; // Red
            private function init():void
                //init code
                super.restrict = '0-9\.\\-';
            private function formatDecimal(val:Number):String
                var decimalFormatter: NumberFormatter = new NumberFormatter();
                decimalFormatter.rounding = 'nearest';
                decimalFormatter.precision = 2;
                decimalFormatter.useNegativeSign = false;
                return decimalFormatter.format(val);
            public function set realValue(value:String):void
                //Set real value
                _realValue = value;
                // format the number here
                super.text = formatDecimal(Number(_realValue));
            public function get realValue():String
                //Return component text real value
                return _realValue;
            override protected function focusInHandler(event:FocusEvent):void
                //Update component text real value
                super.text = _realValue;
            override protected function focusOutHandler(event:FocusEvent):void
                //Check if the source is blank
                if (event.target.text == '')
                    _realValue = '0';
                else
                    _realValue = event.target.text;
                //Update component text value
                super.text =  formatDecimal(Number(_realValue));
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                // Set the font color red for negative numbers
                setStyle('color', (parseFloat(_realValue) < 0) ? NEGATIVE_COLOR : POSITIVE_COLOR);
        ]]>
    </mx:Script>
</mx:TextInput>

Similar Messages

  • How to get the value from textInput Component to perform calculation?

    I need some help here...I'm trying to get the value of user input from the TextInput Component which is the age, height and weight to calculate the bmr and display the result in member("result").text.
    How am i suppose to let the integer pass through in order for me to perform calculation? Would appreciate if anyone can help me out with this, thanks!
    Below are the formula :
    The Harris Benedict equation estimates BMR:
    For women: (9.56 x w) + (1.85 x h) – (4.68 x a) + 655
    For men: (13.75 x w) + (5 x h) – (6.76 x a) + 66

    Assumed that this section is only for male ...it still show error saying script error : String expected for
    on mouseDown
       member("result").text = (13.75 * value(member("weightText").text)) + (5 * value(member("heightText").text)) - (6.76 * value(member("ageText").text)) + 66
    end
    Do i have to add in "put sprite(x).text -- where x is the number of the sprite that is the text input." ?

  • Restrict a textInput component to accept only numbers from 0 to 250

    I want to restrict a textInput component to accept only
    numbers from 0 to 250. I know I can use restrict to some degree but
    all I can do is restrict it to 0-9 and use maxChars to 3 which
    allows any number from 000-999.
    I believe I could use the TextEvent.TEXT_INPUT and then write
    some code that will convert that event's text (i.e. the text
    entered into textInput component before it is actually added to the
    textInput component's text value) such that I do not allow values
    greater than 250 but I'm not sure what that code would be. Does
    anyone know an easier way to do this?

    use the change event to monitor the input value and if it's
    greater than 250 (after typing the text property as a number),
    assign the text property to be "250".

  • Dynamically add component question?

    Hi:
    Here is part of my code in short:
    public class TextInputWithAutoComplete extends TextInput
    private function addComp():void{
    list = new List();
    list.id = "autoCompleteList";
    list.x = 0;
    list.y = 20;
    list.addEventListener(MouseEvent.MOUSE_UP, handleMouseDown);
    parentDocument.addChild(autoCompleteList); OR addChild(autoCompleteList); //my question is here
    private function handleMouseDown():void{
    //TODO
    I realized that if I do addChild, I can't really see the dynamically added component, since flex did not reserve space for my List to display. So I do parentDocument.addChild, and then the component appears no problem. My question is since it's being added in the parentDocument, so it is suppose to be a component belong to parentDocument, so is that component still be able to call this handleMouseDown?
    From my experience, it's still able to, but which doesn't make sense to me.
    Can someone explain a little about why it can still work, or any better approach other than parentDocument.addChild
    Thanks.

    In Flex there is a lifecycle that represents the contract between the component and its parent.  See the chapters on creating custom components and the lifecycle methods createChildren, commitProperties, measure and updateDisplayList.
    Some components size to content like Containers.  When you add a child to a container it will measure the child and make room for it or add scrollbars if there isn't enough room.
    If you add a child to TextInput, it doesn't expect additional children so it will not make room for it.  You can subclass and override its measure and updateDisplayList methods to make room for an additional child.
    I would not recommend adding another interactive control to an interactive control since that will make managing focus and accessibility much harder.  It is better to group these in a container in most cases.
    The reason the mouse handler still gets called is because a handler can be on any object whether it is a child or sibling or parent and will be called by the object dispatching the event if the handler is listening to that object.  If you had attached the handler to "this" it would not get called when the List is not a child of "this".
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Code Structure / Component Question

    I'm new to Flex and trying to learn as much as I can on my own without help, but I've run into a question that I'm not finding an answer for.
    I've read about creating MXML components and understand that, as well as creating AS classes, that that makes sense too.
    I have code in the default package which displays the Datagrid component (MXML) but also has ActionScript code in the same source file to load the datagrid via PHP (HTTPService) as well as define what happens when cells are updated (sending data back to update the DB via PHP).
    This is all pretty much a self-contained "component" for manipulating data from a particular MySLQ table from this single datagrid.  I have the grid displayed on one tab of the tab navigator.
    My problem is that I'd like to create a similar datagrid on a separate tab which does the same thing for a different table.   I know this code needs to be separated and not in one MXML file, but I'm not finding how to either structure my project to do this, or else make each datagrid (along with the associated AS code) into a separate component.
    Would appreciate any help or examples you may have.
    Thanks,
    Gary

    Thanks for pointing me in this direction -- I had started that way, but got confused.  Here are the first few lines of my current code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                            width="998" height="656" creationComplete="init()" layout="absolute">
              <mx:Script>
                        <![CDATA[
                                  import mx.controls.Alert;
                                  import mx.events.PropertyChangeEvent;
                                  import mx.events.CollectionEventKind;
                                  import mx.events.CollectionEvent;
                                  import mx.events.DataGridEvent;
                                  import mx.controls.TextInput;
                                  import mx.rpc.events.ResultEvent;
                                  import mx.collections.ArrayCollection;
                                  import com.adobe.serialization.json.JSON;
                                  import com.adobe.viewsource.ViewSource;
                                  [Bindable]
                                  private var callbackUrl:String;
    Naturally, my datagrid tag is dozens of lines below this:
    <mx:TabNavigator x="23" y="10" width="831" height="506">
    <mx:Canvas width="100%" height="100%" label="Learners">
    <mx:DataGrid id="dgData"
    x="27"
    y="19"
    width="778"
    Can you show me a quick example of how I'd put this together with the top tag as you described?
    Thanks again,
    Gary

  • Flash MX2004 Loader Component Question

    Hi all,
    I have a question regarding the loader component that ships
    with Flash MX 2004. I am using the component to load .swf files. As
    far as I can tell, the component will not begin to play a .swf file
    until it is 100% loaded. Is this correct? If not, is there any way
    to make it play as it is downloading? This IS possible with the
    MovieClipLoader class but I currently have a complex application
    built using the loader component.
    If anyone has any suggestions, I would appreciate it.
    Additionally, I could extend the class if anyone can point me in
    the direction of what would need to be changed in the class.
    Thanks,
    John

    I'm only trying to interpret what that message is telling me in this response.  It seems to be indicating that you have some object in the library that you have named "calLoader" and assigned it a linkage ID of Loader (possibly by default) as well as another object in the library named myLoader that has the same linkage ID (possibly by default).
    If these two objects are the same component type, then you only need one of them in the library.  The different naming of them can be managed on the stage.

  • Distributed Component question

    Hi,
    I've a question about the set-up/architecture of a project. Im thinking of an application which has like 2 screens which is a simple master detail setup. A list contains items of a certain type. Dependant of the type, a specific screen has to be shown with its details. As certain types are financial related and some are human resource related for  example i want a way to seperate them project wise.....This because when i want to fix something in the financial screens, i dont want to impact the human resource stuff with deployment. After reading some things, i got the impression that distributed components could work here. Then i could create a component which is deployed seperately of its main application and doesnt affect other components when a fix is needed. Im i on the right track here?
    Can anyone also point me to a tutorial of how to create a simple distributed component. All i could find was a ppt of a teched which i found quite complicated.
    much thanks & regards,
    Hugo

    Hi Hugo,
    I suggest you to go through componentization articles by Bertram.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/presentation%20-%20web%20dynpro%20component%20interface%20defintions%20in%20practice.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/readme%20-%20web%20dynpro%20component%20interface%20definitions%20in%20practice.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/web%20dynpro%20java%20for%20experts:%20Web%20Dynpro%20Component.pdf
    Regards, Anilkumar

  • Component question with textfield

    I'm creating a keyboard entry component for a touchscreen.
    When the user
    hits the enter button I want to change a textfield in a
    movieclip to the
    text they typed in. The movieclip is outside of the
    component. There maybe a
    screen with multiple text entry boxes. So what I want to do
    is pass in a
    textfield reference into the component using getter and
    setter functions.
    However I am having trouble. Here's an example of what I'm
    doing.
    //mcKeyboard is the component name on the timeline
    //tfDisplay is the textfield on the timeline with the text
    'help' in it
    mcKeyboard.tfEnter = tfDisplay;
    //When I click the enter button in the component, I have the
    script trace
    the text. Here is the enter button script
    trace(tfEnter.text);
    //this displays undefined
    Am I able to pass a textfield or movieclip or something like
    that into a
    component.
    Jeff

    You will have to break the data out of the cluster and present them to the 3d Graph a seperate arrays for X,Y,Z, and W where "W" is your measured values from the locations described by X,Y,Z.
    This thread shows how to plot readings in 3-space. The following image shows the data the original questioner wanted to plot.
    Have fun,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • AS 2.0 Loader component question

    I have a site that has a gallery with 40 images, takes a long
    time to load so I need to find the best way to correct. The files
    that load manually now are movieclips that play in 10 second frames
    in their own timeline with an alpha effect on each all the jpgs and
    other files are in the main fla which is huge because of this. I
    was going to use the loader component but I see you can only use
    for .jpgs and I can't put the effect on jpgs, other obvious way is
    using loadMovie but then I have to convert all mc's to separate
    swfs. Before I go that route is there another way to do this?
    rderf

    I have a site that has a gallery with 40 images, takes a long
    time to load so I need to find the best way to correct. The files
    that load manually now are movieclips that play in 10 second frames
    in their own timeline with an alpha effect on each all the jpgs and
    other files are in the main fla which is huge because of this. I
    was going to use the loader component but I see you can only use
    for .jpgs and I can't put the effect on jpgs, other obvious way is
    using loadMovie but then I have to convert all mc's to separate
    swfs. Before I go that route is there another way to do this?
    rderf

  • Loader Component Question

    Can I have two loader components in one flash file (my main web page)  I have a main loader for my pages to load into when the corresponding button is clicked.  I need to add a second one for a small .swf file of a interactive calendar.  So I guess I need another loader .  I tried to add another loader to my main flash page and it said something like this component is in use or has same name.  I looked in my library and changed the name of my other loader to myLoader and it is still giving this wierd error.  Is is possible to use the Loader component twice in one flash document?   I also don't have them in the first frame of my document because I have an animation that plays through first.

    I'm only trying to interpret what that message is telling me in this response.  It seems to be indicating that you have some object in the library that you have named "calLoader" and assigned it a linkage ID of Loader (possibly by default) as well as another object in the library named myLoader that has the same linkage ID (possibly by default).
    If these two objects are the same component type, then you only need one of them in the library.  The different naming of them can be managed on the stage.

  • HT202696 I hve Apple care on 1 device but the person at the apple store just talked about replacing fried ports and did not answer my broken glass or component questions and nothing in detail is actually posted so im afraid its yet another insurance scam

    I want to know what exactly Apple will fix on say my IPhone 6 plus. Like a dropped device with broken hardware or components or port issue, electrical broken glass etc.. I only have AppleCare on 1 device because I cant get straight answers about repair cost or if it will repair broken glass ,components  etc. The person at Apple just said it will fix ports and did not answer the other question about a real broken device or broken glass. 

    Actually that's not entirely accurate Csound1... If you purchased AppleCare+ it not only extends your warranty an extra year but it also now covers up to two accidental damages (water damage included). Now every scenario is different when you're talking phone damages so it's best to set up a reservation with the Genius Bar if something happens and they'll assess the damage. Either way, as long as you're covered with AppleCare you'll receive a deductible price on parts. Certain instances you may not have to pay anything which are usually things like faulty software, faulty buttons, etc.
    Hope this was helpful!

  • List component question

    Hello,
    I have flash cs4, and I am using a list component. I know how to open swf when somebody clicks on the list, but is there any way to tell the component to open a .pdf file on  a new window using the list component?
    thanks for your guidance
    Cheers.

    You just need to link to the pdf like you would link to any web page.  The code you use depends on the version of actionscript you are using...
    AS2:  getURL("http://www.yourdomain.com/your.pdf", "_blank");
    AS3: navigateToURL(new URLRequest("http://www.yourdomain.com/your.pdf"), "_blank");

  • TextInput Validation question

    Hi,
    I am looking to a validation for TextInput wherein the input has to be:
    1. At least 6 words (yes, not albhabets/characters). Maximum 10 words.
    2. Every word is of at least 2 characters.
    Please provide help/links if you know a solution.
    Thanks,
    Sam

    I think you can do what you want by using the valueCommit event of a TextInput control to trigger validation after a user enters information in the control
    From there I'd use an array from .text.split(' ') to get the list of space separated chars/words.
    You can then check the array length  for number of words
    and the length of each array element for the minimum 2 char requirement.
    My suggestion..
    Don

  • Odd behavior in textInput component

    I ran into this bit of wierdness when porting my application from the beta to the final JSF RI.
    I had the following component in my JSP under the beta
              <h:input_text id       ="pnmpNo"
                            value    ="#{pnmpQueryNo.stringField}"
                            size     ="10"
                            rendered ="#{pnmpQueryNo.empty}" />
              <h:command_button id       ="pnmpTicketSearch"
                                value    ="Lookup PNMP Ticket"
                                action   ="#{pnmpQueryNo.lookupPnmp}"
                                rendered ="#{pnmpQueryNo.empty}">
              </h:command_button>
      and the backing bean had the 'empty' attribute getter defined as follows:
         * Indicate if the circuitList is empty or not
        public boolean isEmpty(){
            return (getCircuits()==null || getCircuits().size()==0);
        }Since the 'empty' attribute is synthetic, I didn't build a setter method. The other attributes have appropriate getters and setters.
    When ported to 1.0 final, I changed the JSP to
              <h:inputText id       ="pnmpNo"
                            value    ="#{pnmpQueryNo.stringField}"
                            size     ="10"
                            rendered ="#{pnmpQueryNo.empty}" />
              <h:commandButton id       ="pnmpTicketSearch"
                                value    ="Lookup PNMP Ticket"
                                action   ="#{pnmpQueryNo.lookupPnmp}"
                                rendered ="#{pnmpQueryNo.empty}">
              </h:commandButton>The beta version worked flawlessly but when I ported to final, I started getting an odd exception:
    javax.faces.el.ReferenceSyntaxException: Encountered "empty" at line 1, column 15.
    Was expecting:
        <IDENTIFIER> ...
         com.sun.faces.application.ApplicationImpl.checkSyntax(ApplicationImpl.java:912)
         com.sun.faces.application.ApplicationImpl.createValueBinding(ApplicationImpl.java:399)
         javax.faces.webapp.UIComponentTag.setProperties(UIComponentTag.java:895)
         com.sun.faces.taglib.html_basic.InputTextTag.setProperties(InputTextTag.java:214)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1026)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1045)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:732)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:425)
         com.sun.faces.taglib.html_basic.InputTextTag.doStartTag(InputTextTag.java:500)
         org.apache.jsp.startQuery_jsp._jspx_meth_h_inputText_0(startQuery_jsp.java:260)
         org.apache.jsp.startQuery_jsp._jspx_meth_h_form_0(startQuery_jsp.java:191)
         org.apache.jsp.startQuery_jsp._jspx_meth_f_view_0(startQuery_jsp.java:144)
         org.apache.jsp.startQuery_jsp._jspService(startQuery_jsp.java:100)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:142)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)I got around the problem by renaming the attribute to 'emptied'
    I dug through the spec and didn't find anything to indicate that 'empty' is not a legal name for an attribute. Is this a bug or did I miss something?

    "empty" is a reserved keyword in JSF EL, JSTL/JSP 2.0 EL (since they all use the same syntax). JSF 1.0 supports (almost) the full range of syntax supported in JSTL/JSP 2.0 EL, whereas the beta supported only a limited subset.
    -- Adam Winer (EG member)

  • Simple image component question

    I have to fix a flash file someone else made, and I need to use an image component, which I'm not familiar with.
    I just need a simple image that scales up, and then moves across the screen. I've got my image component, and tweened it to scale and then move, and it looks fine when I scrub the timeline, but when I test as a swf it doesn't do anything, it just sits there.
    Am I missing something?

    If its working on while dragging the timeline during in authoring and not working while playing the complied swf can mostly mean that u have attached a top command somehwere in ur code which is stopping the timeline from moving forward on playing the swf.Check for unwanted stop commands.

Maybe you are looking for

  • Creating PDF with XML and APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT

    I am trying to generate a PDF report with an existing BLOB stored in a table being applied to a report template. Here is my procedure. declare doc blob; begin select img into doc from table where id = :P1_SEL_ID; APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT ( p

  • How do I get the file name?

    I'm kind of new to javascript -- working with a colleague who has Adobe Acrobat Professional -- I've got an *old* version of Adobe Acrobat and most of the functions don't work -- but how do we get the file name -- we're trying to develop an applicati

  • Supplier constraint in PPDS

    Dear Experts, We wanted to use supplier delivery component quantity to be hard constraint for scheduling/re-scheduling in PP/DS. Please can anyone throw light on this. Thanks, Moorthi

  • Expose "all windows" Annoying problem

    I spent an hour and could not find another post on this problem. I am running the latest version of tiger and I have an imac g5 pre intel. I love expose and have a different command in all four corners. My problem is that the "all windows" feature co

  • Podcast in Chronological Order

    How do I set up my podcast in chronological order? Oldest to newest. My iPod does this, as it is within iTunes.