Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Populating ListGrid datetime fields from custom executeFetch...

    SmartClient v12.0p_2019-06-20/Pro Deployment 2019-06-20
    FireFox

    I am trying to populate a ListGrid datasource datetime field from custom executeFetch java code and having trouble with it.
    My datasource looks like this:
    Code:
    <fields> <field name="rpt_inst" title="ID" type="integer" primaryKey="true" />
       <field name="rpt_date" title="Date" type="datetime" />
       <field name="rpt_user" title="UserID" type="text" length="50" />
       <field name="rpt_no" title="ReportNumber" type="text" length="10" />
       <field name="rpt_status" title="Status" type="text" length="10" />
    </fields>
    My java source to fill the List<Map> looks like this:
    Code:
    @Override
    public List<Map> convertResultSet(ResultSet rs) {
       List<Map> ret = new ArrayList<Map>();
       try {
          while(rs.next()) {
             Map<String, Object> rec = new HashMap<String, Object>();
             rec.put("rpt_inst",rs.getInt("rpt_inst"));
             Timestamp ts = rs.getTimestamp("rpt_datetime");
             Date dt = new Date(ts.getTime());
             rec.put("rpt_datetime",dt);
             rec.put("rpt_user",rs.getString("rpt_user"));
             rec.put("rpt_no",rs.getString("rpt_no"));
             rec.put("rpt_status",rs.getString("rpt_status"));
             ret.add(rec);
          }
       } catch (Exception e) {
          logger.severe("Failed to parse ResultSet");
          e.printStackTrace();
       }
       return ret;
    }
    The above code takes a ResultSet from an appserver call and converts it to Isomorphic's List<Map> ListGrid data via an executeFetch() override. My ListGrid "Date" column is blank; all the other fields are populated. There is no stacktrace or error to speak of. I tried putting the Timestamp object and it doesn't work either. What type of Object do I need to send in the request data to correctly populate the ListGrid datetime column?

    Thanks in advance.
    Last edited by kgunderson; 31st Oct 2019, 11:43.

    #2
    We support many different representations of dates and times, include JODA, LocalDateTime, etc. That's not your problem - your problem is simply that you named your field "rpt_date" but you are populating "rpt_datetime" instead.

    This kind of problem is super easy to troubleshoot - you can just open the RPC tab of the Developer Console and take a look at the response from the server. Then it would be obvious that the date is being sent but your field name just doesn't match.

    Comment


      #3
      [sheepishly] Works now.

      Comment

      Working...
      X