/build.properties/src/wsl/mdn/html/NewRecordDelegate.java

http://mobiledatanow.googlecode.com/ · Java · 78 lines · 41 code · 10 blank · 27 comment · 4 complexity · ef5a3b46bede844971e6fbebe8b257a5 MD5 · raw file

  1. //==============================================================================
  2. // NewRecordDelegate.java
  3. // Copyright (c) 2001 WAP Solutions Ltd.
  4. //==============================================================================
  5. package wsl.mdn.html;
  6. import wsl.fw.servlet.ServletBase;
  7. import wsl.fw.util.Util;
  8. import wsl.fw.resource.ResId;
  9. import wsl.mdn.guiconfig.*;
  10. import wsl.mdn.dataview.*;
  11. import java.io.IOException;
  12. import javax.servlet.ServletException;
  13. //------------------------------------------------------------------------------
  14. /**
  15. * Delegate used by MdnHtmlServlet to ??.
  16. */
  17. public class NewRecordDelegate extends MdnHtmlServletDelegate
  18. {
  19. // version tag
  20. private final static String _ident = "$Date: 2004/01/06 02:09:39 $ $Revision: 1.2 $ "
  21. + "$Archive: /Mobile Data Now/Source/wsl/mdn/html/NewRecordDelegate.java $ ";
  22. //--------------------------------------------------------------------------
  23. /**
  24. * Default constructor.
  25. */
  26. public NewRecordDelegate()
  27. {
  28. }
  29. //--------------------------------------------------------------------------
  30. /**
  31. * Handle actions for the ??Delegate.
  32. * @throws IOException, standard exception thrown by servlet methods.
  33. * @throws ServletException, standard exception thrown by servlet methods.
  34. */
  35. public void run() throws IOException, ServletException
  36. {
  37. try
  38. {
  39. // get the menu action
  40. UserState us = getUserState();
  41. MenuAction ma = us.getCurrentMenu();
  42. // validate
  43. Util.argCheckNull(us);
  44. Util.argCheckNull(ma);
  45. assert ma instanceof NewRecord;
  46. DataView dv = us.getCache().getDataView(ma.getDataViewId());
  47. if(dv != null)
  48. {
  49. // create a record for the dv
  50. Record rec = new Record(dv);
  51. if(rec != null)
  52. {
  53. // set the record into the user state
  54. us.setNewRecord(rec);
  55. // delegate to show record
  56. delegate(new EditRecordDelegate(rec, "-1"));
  57. }
  58. }
  59. }
  60. catch(Exception e)
  61. {
  62. onError(e);
  63. }
  64. }
  65. }
  66. //==============================================================================
  67. // end of file NewRecordDelegate.java
  68. //==============================================================================