• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Validating a percentage?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validating a percentage?


  • Subject: Re: Validating a percentage?
  • From: "Daniele Corti" <email@hidden>
  • Date: Wed, 19 Sep 2007 16:02:45 +0200



2007/9/19, James Cicenia <email@hidden>:
Hello -

I am trying to use the EO validation frameworks and am a bit confused.

I would like a person to be able to enter either a number, or a
percent with the percent sign.
But then I need to strip this out.

Do I have to create a "string" instance variable or can I somehow use
validatePercentLoad in the EO?

% is a String value, so you must parse the string:

<wo:WOTextField value="$str" />

public String str;
public boolean success;

public WOComponent control(){
try{
success = true;
    if(str.indexOf("\u0025") < 0) //No percertage
      {
          Integer i = new Integer(str);
          //do what you want wth the int
      }
      else
       {
           String parsedStr = str.replaceAll("\u0025");
           Integer i = new Integer(parsedStr);
       }
} catch(NumberFormatException e)
{
   //raise the exception for the validation
success = false;
}

if(!success)
    return null; //you need this for the validation

return pageWithName(null);
}
Thanks,
James Cicenia

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (

This email sent to email@hidden



--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden

--
Computers are like air conditioners -- they stop working properly if you open
WINDOWS

--
What about the four lusers of the apocalypse? I nominate:
"advertising", "can't log in", "power switch" and "what backup?"
--Alistair Young
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Validating a percentage? (From: James Cicenia <email@hidden>)

  • Prev by Date: Re: Force Refresh Relation
  • Next by Date: Re: Validating a percentage?
  • Previous by thread: Validating a percentage?
  • Next by thread: Re: Validating a percentage?
  • Index(es):
    • Date
    • Thread