You are not doing anything really wrong,

its not Component.replaceWith that is complaining but the renderer.

Embedding the Form in a Panel is a reasonable solution, alternatively you could add both components and toggle their visibility.

Martin

jar ade schrieb:
Hi all,

I´m trying to replace a Panel with a Form when the user clicks a link like so

public void onClick() {
                getPage().get("content").replaceWith(new
LoginForm("content", new User()));
            }

The old content is a component extending Panel, and the new a
component LoginForm extending Form. I end up with a Runtimeexception
with the message

WicketMessage: Component content must be applied to a tag of type
'form', not '<div id="content5" wicket:id="content"/>'


upon clicking the link. A solution would be to make the LoginForm a
Panel and add a Form to it using

add(new Form()) in which case the replacement works. One panel replaces another.

This usage of Form however, would be at odds with the wicket
documentation ("Using Forms: Subclass wicket.markup.html.form.Form").
Also, the javadoc entry for Component.replaceWith() says that only the
id of the replacing component must be identical (not the type as long
as it is a Component, right?). What am I doing wrong here?

HTML is below

----------------------------------------------------
in Page

<div id="content" wicket:id="content" />
----------------------------------------------------
in old "content" Panel

<wicket:panel>
        <div>
static text
        </div>    
</wicket:panel>
----------------------------------------------------
in replacing form

<form wicket:id="loginform" class="searchsubmit">
        <table>
                <tr>
                        <td><span wicket:id="usernamelabel"
wicket:message="value:loginform.usernamelabel"/></td>
                        <td><input wicket:id="username" id="searchinput"/></td>
                </tr>
                <tr>
                        <td><span wicket:id="passwordlabel"
wicket:message="value:loginform.passwordlabel"/></td>
                        <td><input wicket:id="password" type="password" id="searchinput" 
/></td>
                </tr>
                <tr>
                        <td colspan="2">
                                <input wicket:id="loginbutton" type="submit" 
id="searchsubmit" />
                        </td>
                </tr>
        </table>
</form>
----------------------------------------------------
Any help is appreciated
*/jakob

---------------------------------------------------------------------
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