if you want to switch between a label and a textfield, or any two things
that require unique markup but not big enough to factor out into panels then
you should use fragments

<!-- placeholder -->
<div wicket:id="placeholder"></div>

<wicket:fragment wicket:id="txt"><input type="text"
wicket:id="...."/></wicket:fragment>
<wicket:fragment wicket:id="lbl"><span
wicket:id="label"></span></wicket:fragment>

then simply insert the correct fragment into the placeholder div

if you dont want to see the div and using wicket 1.3 you can use
wicket:container instead of div, eg, <wicket:container
wicket:id="placeholder"></wicket:container>

-igor


On 6/20/07, rc.china <[EMAIL PROTECTED]> wrote:



swaroop wrote:
>
> I can see a few things gond wrong here...
>
> 1> First in the onclick method , this does not refer to the original
> parent
> to which label  was added initially as label is the component u want to
> replace
>
> 2> When u want to add a new component to replace the original component
> in the parent heirarchy , u need to call replace method or replaceWith
> method
>
> 3> Dont create the textfield right at the beginning. Do it in the
onClick
> method.
> Here it just hangs out there until user clicks the link
>
> -swaroop
>

you are right, I have make some mistake.




Timo wrote:
>
> This is suspicious. I don't think you should add components
> to the hierarchy during ajax request processing, and
> definitely not if-else what you add when you have static
> markup (i.e. no repeaters).
>
> Always add both components, and set their visibility as
> needed. Wicket visibility controls whether the comoponent
> produces any markup at all, so it's "stronger" than HTML
> visibility.
>
> With ajax updates of visibility you need a placeholder to
> update around the component (as invisible components don't
> provide any markup which ajax could update).
>
> Best wishes,
> Timo
>
> P.S. Congratulations to Apache Wicket for graduating!
>
>
> --
> Timo Rantalaiho
>
I just show what i want using this simple example. In practice, I have a
menu/tree link and i want to dynamically show different content in one
area
for each menu item or tree item.
If we use placeholders for each of them, it would be terrible.


Thank you guys. I have found another mistake in this example. In the html
template:
<html>
<body>

  <br/>
   Click here
</body>
</html>

The  is ok for wicket.markup.html.basic.Label, however,
wicket.markup.html.form.TextField asks for <input>, so it is
disappointing.
--
View this message in context:
http://www.nabble.com/How-can-we-change-a-component-dynamically-in-Wicket---tf3956267.html#a11227255
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to