Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public Object readField (String name) {
  2.  
  3. Object o = null;
  4. Object[] fieldsArray;
  5. Field f = null;
  6.  
  7. input = form.readString(name);
  8. form.writeString(name,input);
  9. try {
  10. fieldsArray = fields.toArray();
  11. for(int i = 0; i < fieldsArray.length; i++) {
  12. if(((Field)fieldsArray[i]).fieldName.compareTo(name) == 0) {
  13. f = (Field)fieldsArray[i];
  14. break;
  15. }
  16. }
  17. o = f.format.parseObject(input);
  18. try {form.writeString(name + "Error","");} // If a data check failed for this field previously, make the error message disappear.
  19. catch(Exception ComponentNotFoundException) {} // If not, catch the exception and move on.
  20. }
  21. catch(Exception ParseException) {
  22. try {form.writeString(name + "Error","Bad format, please re-enter.");} // If no previous errors, create new error message.
  23. catch(Exception ComponentNotFoundException) {form.addLabel(name + "Error","Bad format, please re-enter.",form.getX(name),form.getY(name)+25);} // Otherwise, update the old error message.
  24. }
  25. return o;
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement