You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "mike.hua" <hz...@sohu.com> on 2013/11/13 11:29:02 UTC

How to set the page title?

Dear All:  Can I change the page title(*set "......" between head tag*) in
java code?  What shoul I do?  Thanks a lot!Mike



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372.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 to set the page title?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Better use #renderHead(IHeaderResponse).

#renderHead(HtmlHeaderContainer) is for internal jobs. This is improved in
7.x to avoid such confusions.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Dec 10, 2015 at 7:44 AM, Martin Makundi <
martin.makundi@koodaripalvelut.com> wrote:

> Another way in overriding class:
>
> /**
>    * @see
>
> org.apache.wicket.Component#renderHead(org.apache.wicket.markup.html.internal.HtmlHeaderContainer)
>    */
>   @Override
>   public void renderHead(HtmlHeaderContainer container) {
>     super.renderHead(container);
>     getResponse().write("<title>" +
> application.getEmployee().getPerson().displayName() + "</title>");
>   }
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4672919.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 to set the page title?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Another way in overriding class:

/**
   * @see
org.apache.wicket.Component#renderHead(org.apache.wicket.markup.html.internal.HtmlHeaderContainer)
   */
  @Override
  public void renderHead(HtmlHeaderContainer container) {
    super.renderHead(container);
    getResponse().write("<title>" +
application.getEmployee().getPerson().displayName() + "</title>");
  }

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4672919.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 to set the page title?

Posted by "mike.hua" <hz...@sohu.com>.
OK, the problem is resolved with your opinion.
Thank you for your help!



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662383.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 to set the page title?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
See my previous e-mail. Add

   *<title wicket:id="pageTitle">Login Page</title>*

Too Template (assuming it is a page). Also

 Label pageTitle = new Label("pageTitle", getTitle());
 this.add(pageTitle);

To template

where get Title is abstract or can ve overriden by super





On Wed, Nov 13, 2013 at 12:13 PM, mike.hua <hz...@sohu.com> wrote:

> Here is the related codes:
> Child page html:
> <?xml version="1.0" encoding="utf-8" ?>
> <!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
> &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:wicket="http://wicket.apache.org">
>     <head>
>         *<title wicket:id="pageTitle">Login Page</title>*
>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
> />
>         <meta name="viewport" content="width=device-width" />
>     </head>
>     <body>
>         *<wicket:extend>
>             <div style="margin:auto;text-align:center;width:40%;">
>                 <form id="loginForm" method="post">
>                     <fieldset id="login">
>                         <legend >Login</legend>
>                         Username: <input type="text" id="username" /><br />
>                         Password: <input type="password" id="password" />
>                         <div>
>                             <input type="submit" name="login" value="login"
> />
>                         </div>
>                     </fieldset>
>                 </form>
>             </div>
>         </wicket:extend>*
>     </body>
> </html>
>
> Child page code:
> /*
>  * To change this license header, choose License Headers in Project
> Properties.
>  * To change this template file, choose Tools | Templates
>  * and open the template in the editor.
>  */
> package my_wicket;
>
> import org.apache.wicket.markup.html.basic.Label;
>
> /**
>  *
>  * @author mike
>  */
> public class ExtendsTemplatePage extends Template {
>
>     public ExtendsTemplatePage() {
>         //Label pageTitle = new Label("pageTitle", "Login Page");
>         //this.add(pageTitle);
>     }
>
>     @Override
>     protected void onInitialize() {
>         super.onInitialize();
>        * Label pageTitle = new Label("pageTitle", "Login Page");
>         this.add(pageTitle);*
>     }
> }
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662380.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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: How to set the page title?

Posted by "mike.hua" <hz...@sohu.com>.
Here is the related codes:
Child page html:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org">
    <head>
        *<title wicket:id="pageTitle">Login Page</title>*
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/>
        <meta name="viewport" content="width=device-width" />
    </head>
    <body>
        *<wicket:extend>
            <div style="margin:auto;text-align:center;width:40%;">
                <form id="loginForm" method="post">
                    <fieldset id="login">
                        <legend >Login</legend>
                        Username: <input type="text" id="username" /><br />
                        Password: <input type="password" id="password" />
                        <div>
                            <input type="submit" name="login" value="login"
/>
                        </div>
                    </fieldset>
                </form>
            </div>
        </wicket:extend>*
    </body>
</html>

Child page code:
/*
 * To change this license header, choose License Headers in Project
Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package my_wicket;

import org.apache.wicket.markup.html.basic.Label;

/**
 *
 * @author mike
 */
public class ExtendsTemplatePage extends Template {

    public ExtendsTemplatePage() {
        //Label pageTitle = new Label("pageTitle", "Login Page");
        //this.add(pageTitle);
    }

    @Override
    protected void onInitialize() {
        super.onInitialize();
       * Label pageTitle = new Label("pageTitle", "Login Page");
        this.add(pageTitle);*
    }
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662380.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 to set the page title?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
getTitle is your own method on Template

proctected abstract IModel<String> getTitle()

then on super classes you provide an implementation.


On Wed, Nov 13, 2013 at 12:23 PM, mike.hua <hz...@sohu.com> wrote:

> *make getTitle() abstract and override it on extensions*??
> Sorry, In 6.x API, I can't find *getTitle()* in WebPage's functions.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662381.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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: How to set the page title?

Posted by "mike.hua" <hz...@sohu.com>.
*make getTitle() abstract and override it on extensions*??
Sorry, In 6.x API, I can't find *getTitle()* in WebPage's functions.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662381.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 to set the page title?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Add it to the parent container... make getTitle() abstract and override it
on extensions?


On Wed, Nov 13, 2013 at 12:07 PM, mike.hua <hz...@sohu.com> wrote:

> Dear Ernesto:
>   *My page extends a parent container.*When I code that,the Exception
> happened.
>   Sorry, I've forgotten to say that.
> Mike
>
> The error message is "Last cause: The component(s) below failed to render.
> Possible reasons could be that: 1) you have added a component in code but
> forgot to reference it in the markup (thus the component will never be
> rendered), 2) if your components were added in a parent container then make
> sure the markup for the child container includes them in <wicket:extend>.1.
> [Component id = pageTitle]"
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662377.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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: How to set the page title?

Posted by "mike.hua" <hz...@sohu.com>.
Dear Ernesto:
  *My page extends a parent container.*When I code that,the Exception
happened.
  Sorry, I've forgotten to say that.
Mike

The error message is "Last cause: The component(s) below failed to render.
Possible reasons could be that: 1) you have added a component in code but
forgot to reference it in the markup (thus the component will never be
rendered), 2) if your components were added in a parent container then make
sure the markup for the child container includes them in <wicket:extend>.1.
[Component id = pageTitle]"



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372p4662377.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 to set the page title?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
<head>
    <title wicket:id="title"></title>

and

public abstract class BasePage extends WebPage {
private static final long serialVersionUID = 1L;

@SuppressWarnings("serial")
public BasePage(final PageParameters parameters) {
super(parameters);
 add( new Label("title", getTitle() ) );

?


On Wed, Nov 13, 2013 at 11:29 AM, mike.hua <hz...@sohu.com> wrote:

> Dear All:  Can I change the page title(*set "......" between head tag*) in
> java code?  What shoul I do?  Thanks a lot!Mike
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-page-title-tp4662372.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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro