The org.zkoss.zk.ui.sys.SEORenderer interface"

From Documentation
m
m
Line 4: Line 4:
 
  org.zkoss.zk.ui.sys.SEORenderer
 
  org.zkoss.zk.ui.sys.SEORenderer
  
A listener could implement <javadoc type="interface">org.zkoss.zk.ui.sys.SEORenderer</javadoc> to generate application-specific SEO content.
+
A listener could implement <javadoc type="interface">org.zkoss.zk.ui.sys.SEORenderer</javadoc> to generate application-specific SEO content. The SEO content could be anything. It is visible to the search engine (for indexing), but it is not visible to the end users<ref>The SEO content will be replaced with the content of ZK components after the page has been rendered.</ref>
 +
 
 +
Notice that the class must implement <javadoc type="interface">org.zkoss.zk.ui.sys.SEORenderer</javadoc>.  <javadoc type="interface" method="render(org.zkoss.zk.ui.Page, java.io.Writer)">org.zkoss.zk.ui.sys.SEORenderer</javadoc> will be invoked each time the main page of a desktop has been rendered and sent to the client<ref>It also means it won't be called in AU requests.</ref>.
 +
 
 +
For example, assume you have an implementation called <code>foo.MySEORenderer</code>, then
 +
 
 +
<source lang="xml">
 +
<!-- in WEB-INF/zk.xml -->
 +
<preference>
 +
    <name>org.zkoss.zk.ui.sys.SEORenderer.class</name>
 +
    <value>foo.MySEORenderer</value>
 +
</preference>
 +
</source>
 +
 
 +
You could generate anything that you'd like the search engine to index in <javadoc type="interface" method="render(org.zkoss.zk.ui.Page,  java.io.Writer)">org.zkoss.zk.ui.sys.SEORenderer</javadoc>:
 +
 
 +
<source lang="java">
 +
package foo;
 +
import org.zkoss.zk.ui.sys.SEORenderer;
 +
import org.zkoss.zk.ui.Page;
 +
public class MySEORenderer implements SEORenderer {
 +
    public void render(Page page, java.io.Writer out)
 +
    throws java.io.IOException {
 +
        out.write("<a href=\"whatever\">whatever</a>");
 +
    }
 +
}
 +
</source>
 +
 
 +
Notice that, if specified, this class will be instantiated and invoked even if [[ZK Configuration Reference/zk.xml/The system-config Element/The crawlable Element|the crawlable option]] is not enabled.
 +
 
 +
= Real Example =
 +
You can also take a look at the ZK's blog about [http://blog.zkoss.org/index.php/2011/03/17/make-zk-application-work-with-seo/ another approach to SEO in ZK Applications].
 +
 
 +
<blockquote>
 +
----
 +
<references/>
 +
</blockquote>
  
 
=Version History=
 
=Version History=

Revision as of 06:30, 20 April 2011


DocumentationZK Configuration Referencezk.xmlThe listener ElementThe org.zkoss.zk.ui.sys.SEORenderer interface
The org.zkoss.zk.ui.sys.SEORenderer interface


Listener:

org.zkoss.zk.ui.sys.SEORenderer

A listener could implement SEORenderer to generate application-specific SEO content. The SEO content could be anything. It is visible to the search engine (for indexing), but it is not visible to the end users[1]

Notice that the class must implement SEORenderer. SEORenderer.render(Page, Writer) will be invoked each time the main page of a desktop has been rendered and sent to the client[2].

For example, assume you have an implementation called foo.MySEORenderer, then

<!-- in WEB-INF/zk.xml -->
<preference>
    <name>org.zkoss.zk.ui.sys.SEORenderer.class</name>
    <value>foo.MySEORenderer</value>
</preference>

You could generate anything that you'd like the search engine to index in SEORenderer.render(Page, Writer):

package foo;
import org.zkoss.zk.ui.sys.SEORenderer;
import org.zkoss.zk.ui.Page;
public class MySEORenderer implements SEORenderer {
    public void render(Page page, java.io.Writer out)
    throws java.io.IOException {
        out.write("<a href=\"whatever\">whatever</a>");
    }
}

Notice that, if specified, this class will be instantiated and invoked even if the crawlable option is not enabled.

Real Example

You can also take a look at the ZK's blog about another approach to SEO in ZK Applications.


  1. The SEO content will be replaced with the content of ZK components after the page has been rendered.
  2. It also means it won't be called in AU requests.

Version History

Last Update : 2011/04/20


Version Date Content
5.0.7 April 2011 Renderer could be specified as a listener.



Last Update : 2011/04/20

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.