Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 117
Registered: ‎10-22-2008
My Device: Not Specified

Advice needed to build a popup filter for a screen

I have a screen that lists some data.

 

I would like to have a menu option to open a popup that has some filter options.

 

I am pretty familiar with the popups and menus and such.

 

How would you recommend:

 

1) Applying the filter?  A local variable on the parent screen that is passed to instance of the popup?

2) Closing the popup?

3) Adding things on the popup such as checkboxes and dropdown controls.

4) Calling an 'update' method back on the parent screen once the filter is applied.

 

Thanks for any suggestions.

 

Eclispse 3.4
JDE 5
Bold/Tour/Storm
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Advice needed to build a popup filter for a screen

1) Applying the filter?  A local variable on the parent screen that is passed to instance of the popup?

Yes, having a local "filter" object passed into the popup constructor is a good idea.

 

2) Closing the popup?

Two buttons - "OK" and "Cancel" (possibly "Apply" as well)

 

3) Adding things on the popup such as checkboxes and dropdown controls.

Just add them to your custom PopupScreen as you normally would.  Of course, if you want to position those in a special way you will have to use (potentially several) HorizontalFieldManager's and VerticalFieldManager's and might need to use an undocumented (before 6.0) but working Field.setMargin().  If you have a specific screen geometry in mind, post here and I'll try to come up with ideas.

 

4) Calling an 'update' method back on the parent screen once the filter is applied.

Do you mean updating the screen once you have a new filter? You may use deleteAll() and add fields according to the new filter. You may have a manager (most probably VerticalFieldManager) populated with new fields in the background then, once it is done, replace the similar displayed one with the new one - then there will no visible transition from one set of records/values to the other, but there might be a delay.

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 117
Registered: ‎10-22-2008
My Device: Not Specified

Re: Advice needed to build a popup filter for a screen

Thanks for the info.

 

That last part...

 

I guess what I mean was how do I actually trigger the event when I close the popup and apply the new filter.

 

Let's say in the parent screen I have an UpdateList(String someFilter) method.

 

when I apply the filter and close the popup, I need to call that method.  How is it triggered?

Eclispse 3.4
JDE 5
Bold/Tour/Storm
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Advice needed to build a popup filter for a screen

The best place would be clicking your OK button.  Either override its (ButtonField's) navigationClick and invoke your parent screen's UpdateList with the new filter (I guess parent screen should be passed as a parameter to your PopupScreen), or use a FieldChangeListener as they suggest in the ButtonField documentation.  Like this:

 

ButtonField okButton = new ButtonField("OK", ButtonField.FOCUSABLE | ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY);

okButton.setChangeListener(new FieldChangeListener() {
  public void fieldChanged(Field field, int context) {
    if (field == okButton) {
      // create your new filter based on your checkboxes etc.
      String newFilter = ...;
      // tell your parent screen to re-select records
      parentScreen.UpdateList(newFilter);
      // close this popup
      close();
  }
});

 

Good luck!

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!