• JasonGardner
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hi everybody!

 

I have a big giant questionnaire, and during my save process in my controller, I want to do some error-checking.  I want to make sure fields aren't more than the 255 characters that they should be.  Here's my "code" that I've gotten to work so far:

 

public PageReference save() { string TestLength = 'ThisShouldBeTheFieldFromTheVisualForcePage'; Integer LengthOfField = TestLength.length(); if (LengthOfField>255) {pop up a window saying that it's too big and break out of page} else {save the questionnaire} }

 

This code works fine, but when I try to replace the value 'ThisShouldBeTheFieldFromTheVisualForcePage' with the actual field, as seen in this code:

 

 

string TestLength = qGeneral.Project_Name__c;

it doesn't seem to work.  It errors out on the "Integer LengthOfField = TestLength.length();" line.  And Eclipse gives an error that says "An unexpected error has occured", which doesn't help me at all.  I tried defining the variable beforehand...I tried checking for "null" before this line thinking that it might not like that.  I just can't get it to work, and I'm sure it's something dumb, but I've been beating myself against the wall for awhile now, and I figure I'd come here and listen to someone tell me how stupid I've been to save some time.

 

Any and all help is extremely appreciated.

 

Thanks!

 

-Jason

Message Edited by JasonGardner on 11-03-2009 07:46 PM

Hi everybody!

 

I have a big giant questionnaire, and during my save process in my controller, I want to do some error-checking.  I want to make sure fields aren't more than the 255 characters that they should be.  Here's my "code" that I've gotten to work so far:

 

public PageReference save() { string TestLength = 'ThisShouldBeTheFieldFromTheVisualForcePage'; Integer LengthOfField = TestLength.length(); if (LengthOfField>255) {pop up a window saying that it's too big and break out of page} else {save the questionnaire} }

 

This code works fine, but when I try to replace the value 'ThisShouldBeTheFieldFromTheVisualForcePage' with the actual field, as seen in this code:

 

 

string TestLength = qGeneral.Project_Name__c;

it doesn't seem to work.  It errors out on the "Integer LengthOfField = TestLength.length();" line.  And Eclipse gives an error that says "An unexpected error has occured", which doesn't help me at all.  I tried defining the variable beforehand...I tried checking for "null" before this line thinking that it might not like that.  I just can't get it to work, and I'm sure it's something dumb, but I've been beating myself against the wall for awhile now, and I figure I'd come here and listen to someone tell me how stupid I've been to save some time.

 

Any and all help is extremely appreciated.

 

Thanks!

 

-Jason

Message Edited by JasonGardner on 11-03-2009 07:46 PM