Results 1 to 5 of 5

Thread: Creating filter

  1. #1
    chaudhas is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Default Creating filter

    I am trying to get current year, current year-1 and current year -2 in a combobox designed through a grid. Code is written below.
    buildSelectTCYearFilterGrid() prepares a grid while getYearList() gets the elements for the combobox.

    public void buildSelectTCYearFilterGrid (TextFormatter text, CurrentSettingsDTO dto, Grid grid)
    throws PersistenceException, RemoteException
    {

    try {

    Map map = this.getYearList();
    logger.debug("getYearList map::"+map);
    Iterator iter = map.keySet().iterator();
    int row = 0;
    grid.setCell(new Integer(0), 0, row);
    int value = 0;

    grid.setCell("Select", 1, row);
    grid.setCell(new Integer(1), 2, row);
    row++;
    while (iter.hasNext()) {
    String s = (String) iter.next();
    grid.setCell(s, 0, row);
    grid.setCell((String)map.get(s), 1, row);
    value = 0;
    if (s.equals(dto.getYear())) {
    value = 1;
    }
    grid.setCell(new Integer(value), 2, row);
    row++;
    }
    } catch (InvalidElementException e) {
    }
    }

    private Map getYearList() {
    Map yearList = new TreeMap(Collections.reverseOrder());
    try {
    Calendar c = new GregorianCalendar();
    int year = c.get(Calendar.YEAR);
    int prev2Year = year-2;
    int prevYear = year-1;

    yearList.put(new Integer(year).toString(),new Integer(year).toString());
    yearList.put(new Integer(prev2Year).toString(),new Integer(prev2Year).toString());
    yearList.put(new Integer(prevYear).toString(),new Integer(prevYear).toString());

    }

    catch(Exception ee)
    {
    logger.debug("Exception in getYearList - ViewHelper : " + ee);
    }

    Above code creates a filter 'select year' with a combo box having default selection as label 'select' while other options as year 2010,2009 and 2008 coming from getYearList().

    Please let me know what needs to be done to get 2010 as default selection followed by 2009 and 2008 in the list.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default

    What is so 'advanced' about your problem?

    kind regards,

    Jos

  3. #3
    chaudhas is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Default

    fyi
    I posted it in "New to Java" only at the first place but dint get any satisfactory response from there.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Where do you have a combobox in your code? I can't see it.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    Which is exactly the comment I made on the original post in the New To Java bit.

    In fact, I'll copy it here...

    "
    Great, but we don't know anything about Grid, so how can we say how to set something as selected on it?

    Assuming it's a JCombobox underneath then you either setSelectedIndex, or setSelectedObject...
    "

    If you want a "satisfactory" response then post a "satisfactory" question.

Similar Threads

  1. Pz Help Simple XSL filter
    By Ginouser in forum XML
    Replies: 0
    Last Post: 01-20-2010, 09:20 PM
  2. Hi please help with a file filter!
    By xbox_nutter in forum New To Java
    Replies: 4
    Last Post: 03-23-2009, 12:09 PM
  3. web content filter or internet filter
    By sundarjothi in forum Advanced Java
    Replies: 3
    Last Post: 05-15-2008, 11:36 AM
  4. Need a filter
    By revathi17 in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •