http://mail-archives.apache.org/mod_mbox/wicket-users/201001.mbox/%3c303141551001110817p7b03f6a0rb93848a012380...@mail.gmail.com%3e

2010/1/21 German Morales <germanamora...@gmail.com>:
> Hallo Alexander,
>
> Perhaps you could change this to be a FormComponent (actually inheriting
> from FormComponentPanel).
> Then, when your ajax call refreshes the "component", the whole div
> (containing drop down + span) will be replaced by a new one.
> In your version, if i understand correctly, wicket removes the old select
> (but not your extra span, of which it is not aware of) and puts the new one
> (which puts another span every time).
>
> Regards,
>
> German
>
> 2010/1/20 Alexander Monakhov <domin...@gmail.com>
>
>> Hi, guys.
>>
>> I'm trying to implement DropDownChoice that could render <select> tag with
>> possiblity to add style with css.
>> What do I mean:
>> <select> tag rendering is OS dependent. So, plain <select> element is
>> always
>> ugly. There is no possibility to change arrow, or border of drop down list
>> only with css.
>> One of the ways to resolve this problem is to add <span> tag before
>> <select>
>> tag to show currently selected value, then apply to it desired background
>> and any desired styles and give <select> tag's opacity zero value. So, drop
>> down menu would appear any time user clicks on span element. To push
>> selected value to span onChange method for <select> tag is appropriated.
>>
>> So, I've created this class:
>> <code>
>> public class StyledDropDownChoice<T> extends DropDownChoice<T> {
>>
>> ....
>> /*Here goes constructors and StyleDropDownSpan is added as behavior. */
>> ....
>>
>>   �...@override
>>    protected void onComponentTag( ComponentTag tag ) {
>>        tag.put( "onChange", "var span = document.getElementById('" +
>> getMarkupId()
>>                + "-span'); var select = document.getElementById('" +
>> getMarkupId()
>>                +  "'); span.innerHTML = select.options[
>> select.selectedIndex ].innerHTML;" );
>>        //todo move javascript output to renderJavascript( CharSequence,
>> String )
>>
>>        super.onComponentTag( tag );
>>    }
>>
>>    private class StyledDropDownSpan extends AbstractBehavior {
>>
>>       �...@override
>>        public void onComponentTag( Component component, ComponentTag tag )
>> {
>>            replaceComponentTagBody( getMarkupStream(), tag,
>>                    "<span class=\"combobox\" id=\"" +
>> component.getMarkupId()
>>                    + "-span\">" + component.getDefaultModelObjectAsString()
>>
>>                    + "</span>" );
>>            super.onComponentTag( component, tag );
>>        }
>>
>>    }
>>
>> }
>> </code>
>>
>> So, this code works fine with usual drop down choices. But, when I'm trying
>> to update list of choice via AJAX call, another span element appear on the
>> page. So, I get that <span> tag is added any time dropdownchoice is
>> rendered. Could you help me to resolve this issue?
>>
>> Best regards, Alexander.
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to