Derek-
Any conversions (String to Integer or whatever) need to happen in your
Business Bean layer
e.g.
ActionForm which uses Strings and booleans
private String IntegerDisplay = null;
public String getIntegerDisplay()
{
 return this.IntegerDisplay();
}
public void setDateIntegerDisplay(String display)
{
 this.IntegerDisplay = display;
}

//Business Bean
public class BusinessBean extends BeanUtils
{
//Default constructor as per spec..
 public BusinessBean() { ; }
 public Integer intn = null;
 public String getIntegerDisplay() {
  try
 {
  intn = getInteger();
  if(ConvertUtils.isNull(intn)) return null;
  return intn.toString();
  }
 catch(NumberFormatException d)
 {
  System.out.println("Bad integer has been passed in do something");
 }
 catch(NullPointerException n)
 {
 System.out.println("Null found you passed me a null Integer!");
 }
}//end getIntegerDisplay

public void setIntegerDisplay(String display)
{
 if(display=null) intn = null;
 else
 {
  try
  { //set the value..
   setDisplay(Integer.valueOf(display));
  }
  catch(Throwable t)
  { //exception found set to null
   setDisplay(null);
  }//end catch
 } //end else
}//end setIntegerDisplay
Now what is that about teaching a man to fish?
Hope this helps,
Martin=
----- Original Message ----- 
From: "Wendy Smoak" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, December 09, 2004 5:02 PM
Subject: Re: Problem with validation (?)


> From: "Derek Broughton" <[EMAIL PROTECTED]>
>
> > > What happens when somebody types "ABCDE" into your Integer field on
the
> > > form, and it fails validation?  Can you re-display the incorrect user
> input
> > > so they can see what they typed and why it was wrong?
> >
> > Or more concisely, because HTML only has string types.
>
> Oh, sure, take all the fun out of it. ;)  Teach a man to fish, and all...
>
> It begs the question though: is there a case for using Integer in an
> ActionForm?  I know the reasons *not* to (and I don't) but it must be
there
> for a reason?
>
> -- 
> Wendy Smoak
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to