Yes, it's make sense.
I change to ptopertyModel and now thinks works.

Thanks Cemal.

2010/2/9 Cemal Bayramoglu <[email protected]>:
> Rangel,
>
> The is a common problem people encounter while they get their head
> aroung Wicket models.
> In your Header class, the label's "data" is only ever calculated once,
> on construction of the Header and is therefore is fixed.
>
> Try something like:
>
>        final Label itens = new Label("itens", new
> PropertyModel(WicketSession.get(),"cart.amount"));
>
> (I have retained your spelling of "itens" but I assume this should be 
> "items").
>
> If you want to format the resulting string (as per your apparent
> intention in your QuickStart), use a converter, probably best in your
> case by overriding the your label's getConverter method.
>
> The rest of your code looks OK.
>
> Does that make sense?
>
> Regards - Cemal
> jWeekend
> OO & Java Technologies, Wicket
> Consulting, Development, Training
> http://jWeekend.com
>
>
>
> On 9 February 2010 14:50, Rangel Preis <[email protected]> wrote:
>> I make a quick start project (maven) to show my problem, if someone have 
>> time...
>>
>> The problem are in HomePage.java in the onClick... this don't reRender
>> my componente in the header.
>>
>> Thanks.
>>
>> 2010/2/9 Rangel Preis <[email protected]>:
>>> I try this again using only setOutputMarkupId without modelChanged and
>>> onModelChange, and don't work.
>>>
>>> I just setOutputMarkupId on my component and in the ajaxEvent i put:
>>> target.addComponent(getPage().get("header:counter"));
>>>
>>> header is a panel and counter is a Label in this panel.
>>>
>>> Thanks All.
>>>
>>>
>>>
>>> 2010/2/8 Rangel Preis <[email protected]>:
>>>> Thanks, Don but this don't work the value don't change. And I call
>>>> setOutputMarkupId when i build it. and call it again later...
>>>>
>>>> Thanks All.
>>>>
>>>> 2010/2/8 Don Ferguson <[email protected]>:
>>>>> I think setOutputMarkupId() should have been called earlier, in the
>>>>> MyTemplate constructor when the Header was constructed.  Ajax processing
>>>>> needs the markup id to find the component you're changing, so setting it 
>>>>> in
>>>>> onModelChanged() is too late.  Also, I don't think you need the call to
>>>>> modelChanged() or to override onModelChanged.  Changing the model object 
>>>>> and
>>>>> adding the component to the target should be sufficient.
>>>>>
>>>>> -Don
>>>>>
>>>>> On Feb 8, 2010, at 2:16 AM, Rangel Preis wrote:
>>>>>
>>>>>> My template HTML
>>>>>>
>>>>>> <html xmlns="http://www.w3.org/1999/xhtml";
>>>>>>
>>>>>> xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd";>
>>>>>>        <head>
>>>>>>                <title wicket:id="title"></title>
>>>>>>                <meta wicket:id="description" name="description"
>>>>>> content=""/>
>>>>>>                <meta wicket:id="keywords" name="keywords" content=""/>
>>>>>>                <meta wicket:id="version" name="version" content=""/>
>>>>>>        </head>
>>>>>>        <body>
>>>>>>
>>>>>>       <a href="#irconteudo" style="display: none;"></a>
>>>>>>
>>>>>>
>>>>>>                <div wicket:id="header" class="header"></div>
>>>>>>
>>>>>>                <!-- conteudo -->
>>>>>>                <div id="conteudo">
>>>>>>                        <table class="layout">
>>>>>>                                <tr>
>>>>>>                                        <td wicket:id="col_esq"
>>>>>> class="col_esq"/>
>>>>>>                                        <td>
>>>>>>                                                <a name="irconteudo"
>>>>>> style="display: none;"></a>
>>>>>>                            <div wicket:id="feedback" id="feedback"/>
>>>>>>                                <wicket:child/>
>>>>>>                                        </td>
>>>>>>                                        <td class="col_dir">
>>>>>>                                        </td>
>>>>>>                                </tr>
>>>>>>                        </table>
>>>>>>                </div>
>>>>>>                <div wicket:id="footer" class="footer"></div>
>>>>>>        </body>
>>>>>> </html>
>>>>>>
>>>>>> Header.html
>>>>>>
>>>>>> <wicket:panel>
>>>>>>   <div class="right">
>>>>>>       <div wicket:id="header_client" class="client"></div>
>>>>>>   </div>
>>>>>>        //Value that i want to change
>>>>>>        <div class="conter">
>>>>>>        <a wicket:id="conter"><span wicket:id="itens"/></a>
>>>>>>   </div>
>>>>>>
>>>>>>   <div class="left">
>>>>>>        <a wicket:id="header_home_link"><div class="logo"/></a>
>>>>>>        </div>
>>>>>>
>>>>>>        <div wicket:id="header_search" class="search"></div>
>>>>>> </wicket:panel>
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> 2010/2/5 Riyad Kalla <[email protected]>:
>>>>>>>
>>>>>>> What do the tasty HTML bits look like? (wicket:ids and what not)
>>>>>>>
>>>>>>> On Fri, Feb 5, 2010 at 12:50 PM, Rangel Preis <[email protected]>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> How can I use Ajax to change value from a parent page in my layout. I
>>>>>>>> try to change values in header using a action from content page.
>>>>>>>>
>>>>>>>> I have this:
>>>>>>>>
>>>>>>>>   |-------------------------------|
>>>>>>>>   |           HEADER           |
>>>>>>>>   |-------------------------------|
>>>>>>>>   | MENU |   CONTENT   |
>>>>>>>>   |             |                       |
>>>>>>>>   |             |                       |
>>>>>>>>   |             |                       |
>>>>>>>>   |-----------|-------------------|
>>>>>>>>   |          FOOTER            |
>>>>>>>>   |-------------------------------|
>>>>>>>>
>>>>>>>> public class MyTemplate{
>>>>>>>>  public MyTemplate() {
>>>>>>>>        super();
>>>>>>>>
>>>>>>>>        this.add(CSSPackageResource.getHeaderContribution(...);
>>>>>>>>
>>>>>>>>        this.add(AbstractTemplatePage.FEEDBACK);
>>>>>>>>
>>>>>>>>        this.addOrReplace(new Header());
>>>>>>>>
>>>>>>>>        this.add(new Menu());
>>>>>>>>
>>>>>>>>        this.add(new Footer());
>>>>>>>>    .....
>>>>>>>>
>>>>>>>>
>>>>>>>> public class MyContetPage extends MyTemplate {
>>>>>>>> public MyContetPage(final PageParameters _parameters) {
>>>>>>>> add(new AjaxFallbackLink<Void>("rem") {
>>>>>>>>
>>>>>>>>   �...@override
>>>>>>>>    public void onClick(final AjaxRequestTarget target) {
>>>>>>>>        …...
>>>>>>>>     }
>>>>>>>>   });
>>>>>>>> ….
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> How change value in the header when i click on the ajaxlink of my
>>>>>>>> content page?
>>>>>>>>
>>>>>>>> In the onClick i try this; but don't work
>>>>>>>>
>>>>>>>> //some function to change the model value...
>>>>>>>> this.getPage().get("header:component").modelChanged();
>>>>>>>> target.addComponent(this.getPage().get("header:component"));
>>>>>>>>
>>>>>>>> And in my Header.java I override onModelChanged:
>>>>>>>>    protected void onModelChanged() {
>>>>>>>>        super.onModelChanged();
>>>>>>>>        this.addOrReplace(component).setOutputMarkupId(true));
>>>>>>>>    }
>>>>>>>>
>>>>>>>> Thanks all.
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>>>> For additional commands, e-mail: [email protected]
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>>> For additional commands, e-mail: [email protected]
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>> For additional commands, e-mail: [email protected]
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [email protected]
>>>>> For additional commands, e-mail: [email protected]
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to