You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sokab <So...@gmail.com> on 2017/05/30 12:32:04 UTC

How reload necessary Panel inside common layout?

Hi. I follow this post 
 ( 
https://stackoverflow.com/questions/24061261/loading-wicket-panels-dynamically-in-a-div
<https://stackoverflow.com/questions/24061261/loading-wicket-panels-dynamically-in-a-div>  
) and try display necessary Panel inside layout but I really can't do it.

I created a sample project:

public class WicketApplication extends WebApplication{
    @Override
    public Class<? extends WebPage> getHomePage()
    {
        return MainPage.class;
    }

    @Override
    protected void init() {
        super.init();        
    }
}

***************************************************************************
MainPage.html:

<html xmlns:wicket="http://wicket.apache.org">
    <head> .... </head>
    <body>
        <div>Main Page</div>
        <wicket:container wicket:id="panel1"></wicket:container>
               
            <wicket:child />       
                  
    </body>
</html>


MainPage.java:

public class MainPage extends WebPage{
    
    @Override
    protected void onInitialize() {
        super.onInitialize(); 
        
        add(new Panel1("panel1"));      
    }
}

***************************************************************************
Panel1.html:
<html xmlns:wicket="http://wicket.apache.org">

    <wicket:panel>
        <wicket:container wicket:id="panel2"></wicket:container>
    </wicket:panel>

</html>


Panel1.java:
public class Panel1 extends Panel{
    
    public Panel1(String id) {
        super(id);
    }

    @Override
    protected void onInitialize() {
        super.onInitialize(); 
        
        add(new Panel2("panel2"));     
    }    
}

***************************************************************************
Panel2.html:
<html xmlns:wicket="http://wicket.apache.org">    
    <wicket:panel>
        
        <div>
             Page1 <#>  
             Page2 <#>  
        </div>
    
    </wicket:panel>
</html>


Panel2.java:
public class Panel2 extends Panel{

    public Panel2(String id) {
        super(id);        
    }

    @Override
    protected void onInitialize() {
        super.onInitialize(); 
        
        
        add(new AjaxLink("page3") {
            @Override
            public void onClick(AjaxRequestTarget target) {
               // ??
            }
        });
       
    
        add(new AjaxLink("page4") {
            @Override
            public void onClick(AjaxRequestTarget target) {
//                ??
            }
        });    
        
    }
}

***************************************************************************
Panel3.html:
<html xmlns:wicket="http://wicket.apache.org">    
    <wicket:panel>        
            <div>
Panel 3 Content
</div>        
    </wicket:panel>
</html>

Panel3.java:
public class Panel3 extends Panel{
    public Panel3(String id) {
        super(id);
    }
}

***************************************************************************
Panel4.html:
<html xmlns:wicket="http://wicket.apache.org">    
    <wicket:panel>        
            <div>
Panel 4 Content
</div>        
    </wicket:panel>
</html>

Panel4.java:
public class Panel4 extends Panel{
    public Panel4(String id) {
        super(id);
    }
}
**********************************************************************************
After clicked on AjaxLink inside Panel2 I need display panel3 or panel4 in
MainPage without reload all page. How can I do this?  Can I call
wicket:id="homePanel" from MainPage.html inside Panel2.java and and replace
panel3/panel4 after ajax request? Thank You for any hint.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-reload-necessary-Panel-inside-common-layout-tp4677948.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How reload necessary Panel inside common layout?

Posted by Sokab <So...@gmail.com>.
Thank You very much!!!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-reload-necessary-Panel-inside-common-layout-tp4677948p4677977.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How reload necessary Panel inside common layout?

Posted by Francois Meillet <fr...@gmail.com>.
Hi Sokab,

Please find a quickstart with Ajax examples !

have fun !


Re: How reload necessary Panel inside common layout?

Posted by Sokab <So...@gmail.com>.
Thanks for reply I suppose I have to add my component panel to
AjaxRequestTarget (target.add(panel) itp..) but my problem is that I do not
understand how handle panels (Panel3 / 4) inside Panel2 and redirect
(display) to some WebPage (MainPage). When I use simple page it is ok  (just
I am expanding my parent class  add BookmarkablePageLink and <wicket:extend>
in html ) but when I use panels I do not know how to handle it. I'm sorry
for English

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-reload-necessary-Panel-inside-common-layout-tp4677948p4677969.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How reload necessary Panel inside common layout?

Posted by Francois Meillet <fr...@gmail.com>.
Have a look at https://ci.apache.org/projects/wicket/guide/8.x/single.html#_working_with_ajax <https://ci.apache.org/projects/wicket/guide/8.x/single.html#_working_with_ajax>


François



> Le 30 mai 2017 à 14:32, Sokab <So...@gmail.com> a écrit :
> 
> Hi. I follow this post 
> ( 
> https://stackoverflow.com/questions/24061261/loading-wicket-panels-dynamically-in-a-div
> <https://stackoverflow.com/questions/24061261/loading-wicket-panels-dynamically-in-a-div>  
> ) and try display necessary Panel inside layout but I really can't do it.
> 
> I created a sample project:
> 
> public class WicketApplication extends WebApplication{
>    @Override
>    public Class<? extends WebPage> getHomePage()
>    {
>        return MainPage.class;
>    }
> 
>    @Override
>    protected void init() {
>        super.init();        
>    }
> }
> 
> ***************************************************************************
> MainPage.html:
> 
> <html xmlns:wicket="http://wicket.apache.org">
>    <head> .... </head>
>    <body>
>        <div>Main Page</div>
>        <wicket:container wicket:id="panel1"></wicket:container>
> 
>            <wicket:child />       
> 
>    </body>
> </html>
> 
> 
> MainPage.java:
> 
> public class MainPage extends WebPage{
> 
>    @Override
>    protected void onInitialize() {
>        super.onInitialize(); 
> 
>        add(new Panel1("panel1"));      
>    }
> }
> 
> ***************************************************************************
> Panel1.html:
> <html xmlns:wicket="http://wicket.apache.org">
> 
>    <wicket:panel>
>        <wicket:container wicket:id="panel2"></wicket:container>
>    </wicket:panel>
> 
> </html>
> 
> 
> Panel1.java:
> public class Panel1 extends Panel{
> 
>    public Panel1(String id) {
>        super(id);
>    }
> 
>    @Override
>    protected void onInitialize() {
>        super.onInitialize(); 
> 
>        add(new Panel2("panel2"));     
>    }    
> }
> 
> ***************************************************************************
> Panel2.html:
> <html xmlns:wicket="http://wicket.apache.org">    
>    <wicket:panel>
> 
>        <div>
>             Page1 <#>  
>             Page2 <#>  
>        </div>
> 
>    </wicket:panel>
> </html>
> 
> 
> Panel2.java:
> public class Panel2 extends Panel{
> 
>    public Panel2(String id) {
>        super(id);        
>    }
> 
>    @Override
>    protected void onInitialize() {
>        super.onInitialize(); 
> 
> 
>        add(new AjaxLink("page3") {
>            @Override
>            public void onClick(AjaxRequestTarget target) {
>               // ??
>            }
>        });
> 
> 
>        add(new AjaxLink("page4") {
>            @Override
>            public void onClick(AjaxRequestTarget target) {
> //                ??
>            }
>        });    
> 
>    }
> }
> 
> ***************************************************************************
> Panel3.html:
> <html xmlns:wicket="http://wicket.apache.org">    
>    <wicket:panel>        
>            <div>
> Panel 3 Content
> </div>        
>    </wicket:panel>
> </html>
> 
> Panel3.java:
> public class Panel3 extends Panel{
>    public Panel3(String id) {
>        super(id);
>    }
> }
> 
> ***************************************************************************
> Panel4.html:
> <html xmlns:wicket="http://wicket.apache.org">    
>    <wicket:panel>        
>            <div>
> Panel 4 Content
> </div>        
>    </wicket:panel>
> </html>
> 
> Panel4.java:
> public class Panel4 extends Panel{
>    public Panel4(String id) {
>        super(id);
>    }
> }
> **********************************************************************************
> After clicked on AjaxLink inside Panel2 I need display panel3 or panel4 in
> MainPage without reload all page. How can I do this?  Can I call
> wicket:id="homePanel" from MainPage.html inside Panel2.java and and replace
> panel3/panel4 after ajax request? Thank You for any hint.
> 
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-reload-necessary-Panel-inside-common-layout-tp4677948.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>