it doesnt work because of this:

protected boolean wantOnSelectionChangedNotificat
ions() {
                return true;
            }

this makes the onchange a non-ajax refresh, so the indicator is not invoked.

-Igor



On 10/5/06, Konstantinos Lazouras < [EMAIL PROTECTED]> wrote:
Hi,

I use two linked DropDownChoice components, just like the linked select boxes example.
When the first choice is made, I go back to db to get the choices for the second select,
but this takes a few seconds. I 'm trying to put an indicator next to the second select
box while this happens, but it doesn't work. I do the following:

I make a new DropDownChoice class like this:

    public final class IndicatorDropDownChoice extends DropDownChoice implements wicket.ajax.IAjaxIndicatorAware {
        private final WicketAjaxIndicatorAppender indicatorAppender = new WicketAjaxIndicatorAppender();

        public IndicatorDropDownChoice(String id, PropertyModel model, IModel iModel, ChoiceRenderer cr){
            super(id, model, iModel, cr);
            add(indicatorAppender);
        }
        public java.lang.String getAjaxIndicatorMarkupId(){
            return indicatorAppender.getMarkupId();
        }
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }
    }
   
Inside the form, I make the selects like this:

    // countries
    List countryList = packModel.loadCountries();
    final DropDownChoice countrySelection = new DropDownChoice("countrySelection", new PropertyModel(packModel,
                "countrySelection"), countryList, new CountryChoiceRenderer());
    countrySelection.setOutputMarkupId(true);
    add(countrySelection);

    // cities
    // reload the choices on display
    IModel cityChoices = new AbstractReadOnlyModel() {
        public Object getObject(Component component) {
            return packModel.loadCities();
        }
    };

    final DropDownChoice citySelection = new IndicatorDropDownChoice("citySelection", new PropertyModel(packModel,
                "citySelection"), cityChoices, new CityChoiceRenderer());
    citySelection.setOutputMarkupId(true);
    add(citySelection);

    // OnChange Ajax actions for countries
    countrySelection.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
            target.addComponent(countrySelection);
            citySelection.modelChanging();
            target.addComponent(citySelection);
            citySelection.modelChanged();
        }
    });

    // OnChange Ajax actions for cities
    citySelection.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
//            target.addComponent (citySelection);
        }
    });


When I select a country, the 2nd select populates with options but the indicator image
next to it doesn't show up while this happens ("Choose one" option is still the selected
at the end, which is ok).
If I select a city, the image next to the 2nd box appears, stays for about 15 seconds
and then hides (I expected it to appear for less than a second, as long as the change
lasts).
If I uncommend the line "target.addComponent(citySelection);", then the same happens but
the indicator never goes away. Furthermore, when I select another city, a second indicator
image appears next to the first (which also stays forever) and so on.

The html code of the page is (with the above line uncommended):

    <tr>
     <td class="label">Country </td>
     <td>
      <select name="countrySelection" wcall=wicketAjaxPost('/projectA/queryPage?x=6-%3A3%3ApackForm%3AcountrySelection%3A%3AIBehaviorListener&wicket:behaviorId=1', wicketSerialize( document.getElementById('packForm_countrySelection')), function() { }, function() { });" id="packForm_countrySelection">
        <option selected="selected" value="">Choose One</option>
        <option value="0">Cambodia</option>
        <option value="1">Greece</option>
        <option value="2">Italy</option>
        <option value="3">Maldives</option>
        <option value="4">Singapore</option>
        <option value="5">Thailand</option>
      </select>
     </td>
    </tr>
    <tr>
     <td class="label">City</td>
     <td>
      <select name="citySelection" id="packForm_citySelection" wcall=wicketAjaxPost('/projectA/queryPage?x=6-%3A3%3ApackForm%3AcitySelection%3A%3AIBehaviorListener&wicket:behaviorId=2', wicketSerialize( document.getElementById('packForm_citySelection')), function() { ;wicketHide('packForm_citySelection--ajax-indicator');}, function() { ;wicketHide('packForm_citySelection--ajax-indicator');});">
        <option selected="selected" value="">Choose One</option>
      </select>
      <span style="display:none;" class="wicket-ajax-indicator" id="packForm_citySelection--ajax-indicator">
        <img src=""
      </span>
     </td>
    </tr>

City and Country are objects and the renderers just return their names. I use wicket-1.2.2.

Can you point me to a solution? What am I doing wrong?

Thanx,
Kostas




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to