
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>doOriented.com &#187; Programming</title>
	<atom:link href="http://www.dooriented.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dooriented.com/blog</link>
	<description>Less words, more code</description>
	<lastBuildDate>Thu, 25 Jun 2009 01:23:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wicket Component &#8211; Simple Breadcrumbs</title>
		<link>http://www.dooriented.com/blog/2009/05/12/wicket-component-simple-breadcrumbs/</link>
		<comments>http://www.dooriented.com/blog/2009/05/12/wicket-component-simple-breadcrumbs/#comments</comments>
		<pubDate>Tue, 12 May 2009 12:29:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=57</guid>
		<description><![CDATA[




A very simple simple wicket component to display links in an hierarchical order. You can see it live here
Full sources are available here.
This is how you add it to the page:
Java

		add(new Breadcrumbs(&#34;breadcrumbs&#34;,
			Arrays.asList(new WCLink[]{
					new WCLink(&#34;Web application section 1&#34;, &#34;http://www.1.com&#34;),
					new WCLink(&#34;Web application section 11&#34; , &#34;http://www.11.com&#34;),
					new WCLink(&#34;Web application section 111&#34;, &#34;http://www.111.com&#34;)
			}),this));

HTML






&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.1//EN&#34; &#34;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&#34;&#62;
&#60;html [...]]]></description>
			<content:encoded><![CDATA[<p>A very simple simple wicket component to display links in an hierarchical order. You can see it live <a target='_new' href="http://www.dooriented.com/wicketcomponents/breadcrumbs.html">here</a></p>
<p>Full sources are available <a href="http://www.dooriented.com/wicketcomponents/resources/wicketcomponents-0.1.jar">here</a>.</p>
<p>This is how you add it to the page:</p>
<p><b>Java</b></p>
<pre class="brush: java">
		add(new Breadcrumbs(&quot;breadcrumbs&quot;,
			Arrays.asList(new WCLink[]{
					new WCLink(&quot;Web application section 1&quot;, &quot;http://www.1.com&quot;),
					new WCLink(&quot;Web application section 11&quot; , &quot;http://www.11.com&quot;),
					new WCLink(&quot;Web application section 111&quot;, &quot;http://www.111.com&quot;)
			}),this));
</pre>
<p><b>HTML</b></p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns:wicket&gt;
&lt;body&gt;
    &lt;div wicket:id=&quot;breadcrumbs&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Wicket component code:<br />
<b>Breadcrumbs.html</b></p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns:wicket&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;wicket:panel&gt;
    &lt;!--
    Wicket component:   JQuery Accordion Menu
    Author:             Nova Creator Software
    Website:            www.novacreator.com
    Software provided as is, without any guarantees.
    Free for any type of usage. We just kindly ask to keep this message.
    --&gt;
    &lt;ul id=&quot;breadcrumbs&quot;&gt;
        &lt;li wicket:id=&quot;repeater&quot;&gt;&lt;a wicket:id=&quot;link&quot;&gt;&lt;span wicket:id=&quot;linkName&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/wicket:panel&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><b>Breadcrumbs.java</b></p>
<pre class="brush: java">
package com.novacreator.wicketcomponents.breadcrumbs;

import java.util.List;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.html.resources.CompressedResourceReference;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.Model;

import com.novacreator.wicketcomponents.common.WCLink;

/*
Wicket component:   Breadcrumbs
Author:             Nova Creator Software
Website:            www.novacreator.com
Software provided as is, without any guarantees.
Free for any type of usage. We just kindly ask to keep this message.
*/
@SuppressWarnings(&quot;serial&quot;)
public class Breadcrumbs extends Panel {
	private static final ResourceReference CSS =
		new CompressedResourceReference(Breadcrumbs.class, &quot;res/breadcrumbs.css&quot;);

	public Breadcrumbs(String id, List&lt;WCLink&gt; links, final BreadcrumbsListener listener) {
		super(id);

		add(HeaderContributor.forCss(CSS));

		RepeatingView rv = new RepeatingView(&quot;repeater&quot;);
		add(rv);
		AjaxFallbackLink afl = null;
		for(final WCLink link : links) {
			WebMarkupContainer wmc = new WebMarkupContainer(rv.newChildId());
			rv.add(wmc);
			afl = new AjaxFallbackLink(&quot;link&quot;){
				@Override
				public void onClick(AjaxRequestTarget target) {
					if(link.getLink() != null &amp;&amp; !link.getLink().isEmpty()) {
						listener.onBreadcrumbsClick(link.getLink(), target);
					}
				}
			};
			wmc.add(afl);
			afl.add(new Label(&quot;linkName&quot;, link.getDisplayName()));
		}
		afl.add(new AttributeModifier(&quot;style&quot;, true, new Model(&quot;background:none;&quot;)));
	}
}
</pre>
<p><b>BreadcrumbsListener.java</b></p>
<pre class="brush: java">
package com.novacreator.wicketcomponents.breadcrumbs;

import org.apache.wicket.ajax.AjaxRequestTarget;

/*
Wicket component:   Breadcrumbs
Author:             Nova Creator Software
Website:            www.novacreator.com
Software provided as is, without any guarantees.
Free for any type of usage. We just kindly ask to keep this message.
*/
public interface BreadcrumbsListener {
	public void onBreadcrumbsClick(String link, AjaxRequestTarget target);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/12/wicket-component-simple-breadcrumbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wicket Component &#8211; JQuery Accordion Menu</title>
		<link>http://www.dooriented.com/blog/2009/05/11/wicket-component-jquery-accordion-menu/</link>
		<comments>http://www.dooriented.com/blog/2009/05/11/wicket-component-jquery-accordion-menu/#comments</comments>
		<pubDate>Mon, 11 May 2009 09:11:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=48</guid>
		<description><![CDATA[Presenting a very simple wicket component for everybody to use &#8211; a JQuery accordion menu. 
You can see it live here
Full sources are available here
This is how you add it to the page:
Java

		Map&#60;AccordionLink, List&#60;AccordionLink&#62;&#62; menus = new LinkedHashMap&#60;AccordionLink, List&#60;AccordionLink&#62;&#62;();
		menus.put(new AccordionLink(&#34;Menu1&#34;, &#34;http://www.menu1.com&#34;),
				Arrays.asList(
						new AccordionLink(&#34;11&#34;, &#34;http://www.menu11.com&#34;),
						new AccordionLink(&#34;12&#34;, &#34;http://www.menu12.com&#34;),
						new AccordionLink(&#34;13&#34;, &#34;http://www.menu13.com&#34;)));
		menus.put(new AccordionLink(&#34;Menu2&#34;, &#34;http://www.menu2.com&#34;),
				Arrays.asList(
						new AccordionLink(&#34;21&#34;, &#34;http://www.menu21.com&#34;),
						new AccordionLink(&#34;22&#34;, &#34;http://www.menu22.com&#34;),
						new AccordionLink(&#34;23&#34;, &#34;http://www.menu23.com&#34;)));
		menus.put(new [...]]]></description>
			<content:encoded><![CDATA[<p>Presenting a very simple wicket component for everybody to use &#8211; a JQuery accordion menu. </p>
<p>You can see it live <a  target='_new' href="http://www.dooriented.com/wicketcomponents/accordion_menu.html">here</a></p>
<p>Full sources are available <a href="http://www.dooriented.com/blog/resources/wicketcomponents.jar">here</a></p>
<p>This is how you add it to the page:</p>
<p><b>Java</b></p>
<pre class="brush: java">
		Map&lt;AccordionLink, List&lt;AccordionLink&gt;&gt; menus = new LinkedHashMap&lt;AccordionLink, List&lt;AccordionLink&gt;&gt;();
		menus.put(new AccordionLink(&quot;Menu1&quot;, &quot;http://www.menu1.com&quot;),
				Arrays.asList(
						new AccordionLink(&quot;11&quot;, &quot;http://www.menu11.com&quot;),
						new AccordionLink(&quot;12&quot;, &quot;http://www.menu12.com&quot;),
						new AccordionLink(&quot;13&quot;, &quot;http://www.menu13.com&quot;)));
		menus.put(new AccordionLink(&quot;Menu2&quot;, &quot;http://www.menu2.com&quot;),
				Arrays.asList(
						new AccordionLink(&quot;21&quot;, &quot;http://www.menu21.com&quot;),
						new AccordionLink(&quot;22&quot;, &quot;http://www.menu22.com&quot;),
						new AccordionLink(&quot;23&quot;, &quot;http://www.menu23.com&quot;)));
		menus.put(new AccordionLink(&quot;Menu3&quot;, &quot;http://www.menu3.com&quot;),
				Arrays.asList(
						new AccordionLink(&quot;31&quot;, &quot;http://www.menu31.com&quot;),
						new AccordionLink(&quot;32&quot;, &quot;http://www.menu32.com&quot;),
						new AccordionLink(&quot;33&quot;, &quot;http://www.menu33.com&quot;)));
		menus.put(new AccordionLink(&quot;Menu4&quot;, &quot;http://www.menu2.com&quot;),
				Arrays.asList(
						new AccordionLink(&quot;41&quot;, &quot;http://www.menu41.com&quot;),
						new AccordionLink(&quot;42&quot;, &quot;http://www.menu42.com&quot;),
						new AccordionLink(&quot;43&quot;, &quot;http://www.menu43.com&quot;)));
		menus.put(new AccordionLink(&quot;Menu5&quot;, &quot;http://www.menu2.com&quot;),
				Arrays.asList(
						new AccordionLink(&quot;51&quot;, &quot;http://www.menu51.com&quot;),
						new AccordionLink(&quot;52&quot;, &quot;http://www.menu52.com&quot;),
						new AccordionLink(&quot;53&quot;, &quot;http://www.menu53.com&quot;)));
		add(new AccordionMenu(&quot;menu&quot;, menus, true, this));
</pre>
<p>The important line is add(new AccordionMenu(&#8221;menu&#8221;, menus, true, this));</p>
<p><b>HTML</b></p>
<pre class="brush: html">
&lt;html xmlns:wicket&gt;
&lt;body&gt;
    &lt;div wicket:id=&quot;menu&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Wicket component code:<br />
<b>AccordionMenu.html</b></p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns:wicket&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;wicket:panel&gt;
    &lt;!--
    Wicket component:   JQuery Accordion Menu
    Author:             Nova Creator Software
    Website:            www.novacreator.com
    Software provided as is, without any guarantees.
    Free for any type of usage. We just kindly ask to keep this message.
     --&gt;
    &lt;div wicket:id=&quot;topdiv&quot; class=&quot;menu_list&quot;&gt;
        &lt;p wicket:id=&quot;repeatItems&quot; class=&quot;menu_head&quot;&gt;
            &lt;span wicket:id=&quot;menuItem&quot;&gt;&lt;/span&gt;
	        &lt;div class=&quot;menu_body&quot;&gt;
	             &lt;a wicket:id=&quot;menuSubItem&quot;&gt;
	                &lt;span wicket:id=&quot;menuSubItemName&quot;/&gt;
	             &lt;/a&gt;
	        &lt;/div&gt;
        &lt;/p&gt;
    &lt;/div&gt;
&lt;/wicket:panel&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><b>AccordionMenu.java</b></p>
<pre class="brush: java">
package com.novacreator.wicketcomponents.jquery.accordionmenu;

import java.util.List;
import java.util.Map;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.html.resources.CompressedResourceReference;
import org.apache.wicket.markup.html.resources.JavascriptResourceReference;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.Model;

/*
    Wicket component:   JQuery Accordion Menu
    Author:             Nova Creator Software
    Website:            www.novacreator.com
    Software provided as is, without any guarantees.
    Free for any type of usage. We just kindly ask to keep this message.
 */
@SuppressWarnings(&quot;serial&quot;)
public class AccordionMenu extends Panel {
	private static final ResourceReference JQUERYJS =
		new JavascriptResourceReference(AccordionMenu.class, &quot;../res/jquery.js&quot;);
	private static final ResourceReference ACCORDIONJS =
		new JavascriptResourceReference(AccordionMenu.class, &quot;../res/accordionmenu.js&quot;);
	private static final ResourceReference CSS =
		new CompressedResourceReference(AccordionMenu.class, &quot;../res/accordionmenu.css&quot;);

	public AccordionMenu(String id, final Map&lt;AccordionLink, List&lt;AccordionLink&gt;&gt; menus, boolean autoExpand, final AccordionMenuListener listener) {
		super(id);

		add(HeaderContributor.forJavaScript(JQUERYJS));
		add(HeaderContributor.forJavaScript(ACCORDIONJS));
		add(HeaderContributor.forCss(CSS));

		WebMarkupContainer topDiv = new WebMarkupContainer(&quot;topdiv&quot;);
		add(topDiv);
		if(autoExpand) {
			topDiv.add(new AttributeModifier(&quot;id&quot;, true, new Model(&quot;autoexpand&quot;)));
		} else {
			topDiv.add(new AttributeModifier(&quot;id&quot;, true, new Model(&quot;noautoexpand&quot;)));
		}
		RepeatingView menuItems = new RepeatingView(&quot;repeatItems&quot;);
		topDiv.add(menuItems);

		for(final AccordionLink menu : menus.keySet()) {
			WebMarkupContainer wmc = new WebMarkupContainer(menuItems.newChildId());
			menuItems.add(wmc);
			wmc.add(new AjaxEventBehavior(&quot;onclick&quot;){
				@Override
				protected void onEvent(AjaxRequestTarget target) {
					if(menu.getLink() != null &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; !menu.getLink().isEmpty()) {
						listener.onAccordionMenuClick(menu.getLink(), target);
					}
				}
			});
			wmc.add(new Label(&quot;menuItem&quot;, menu.getDisplayName()));
			RepeatingView menuSubItems = new RepeatingView(&quot;menuSubItem&quot;);
			wmc.add(menuSubItems);
			for(final AccordionLink item : menus.get(menu)) {
				AjaxFallbackLink iaf = new AjaxFallbackLink(menuSubItems.newChildId()) {
					@Override
					public void onClick(AjaxRequestTarget target) {
						if(item.getLink() != null &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; !item.getLink().isEmpty()) {
							listener.onAccordionMenuClick(item.getLink(), target);
						}
					}
				};
				iaf.add(new Label(&quot;menuSubItemName&quot;, item.getDisplayName()));
				menuSubItems.add(iaf);
			}
		}
	}
}
</pre>
<p><b>AccordionMenuListener.java</b></p>
<pre class="brush: java">
package com.novacreator.wicketcomponents.jquery.accordionmenu;

import org.apache.wicket.ajax.AjaxRequestTarget;

/*
Wicket component:   JQuery Accordion Menu
Author:             Nova Creator Software
Website:            www.novacreator.com
Software provided as is, without any guarantees.
Free for any type of usage. We just kindly ask to keep this message.
*/
public interface AccordionMenuListener {
	public void onAccordionMenuClick(String link, AjaxRequestTarget target);
}
</pre>
<p><b>AccordionLink.java</b></p>
<pre class="brush: java">
package com.novacreator.wicketcomponents.jquery.accordionmenu;

import java.io.Serializable;

/*
Wicket component:   JQuery Accordion Menu
Author:             Nova Creator Software
Website:            www.novacreator.com
Software provided as is, without any guarantees.
Free for any type of usage. We just kindly ask to keep this message.
*/
@SuppressWarnings(&quot;serial&quot;)
public class AccordionLink implements Serializable {
	private String displayName;
	private String link;

	public AccordionLink(String displayName, String link) {
		this.displayName = displayName;
		this.link = link;
	}

	public String getDisplayName() {
		return displayName;
	}
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	public String getLink() {
		return link;
	}
	public void setLink(String link) {
		this.link = link;
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/11/wicket-component-jquery-accordion-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to prevent IFrame to display your website</title>
		<link>http://www.dooriented.com/blog/2009/05/08/how-to-prevent-iframe-to-display-your-website/</link>
		<comments>http://www.dooriented.com/blog/2009/05/08/how-to-prevent-iframe-to-display-your-website/#comments</comments>
		<pubDate>Fri, 08 May 2009 12:23:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=45</guid>
		<description><![CDATA[If you don&#8217;t want your webpage to be displayed inside another website, in an IFrame, use this:

&#60;script type=&#34;text/javascript&#34;&#62;
&#60;!--
if (top.location.href != self.location.href)
  top.location.href = self.location.href;
//--&#62;
&#60;/script&#62;

]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t want your webpage to be displayed inside another website, in an IFrame, use this:</p>
<pre class="brush: php">
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
if (top.location.href != self.location.href)
  top.location.href = self.location.href;
//--&gt;
&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/08/how-to-prevent-iframe-to-display-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java interface contract</title>
		<link>http://www.dooriented.com/blog/2009/05/08/java-interface-contract/</link>
		<comments>http://www.dooriented.com/blog/2009/05/08/java-interface-contract/#comments</comments>
		<pubDate>Thu, 07 May 2009 23:09:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=40</guid>
		<description><![CDATA[Suppose you have an interface defined like this:
interface someInterface {
Object someMethod(Object someObject);
}
First thing you have to know is that interfaces are only public if you define them as such. If you don&#8217;t they can only be implemented by classes in that package. 
Just like the interfaces themselves, the methods defined in an interface are public [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose you have an interface defined like this:</p>
<p>interface someInterface {</p>
<p>Object someMethod(Object someObject);</p>
<p>}</p>
<p>First thing you have to know is that interfaces are only public if you define them as such. If you don&#8217;t they can only be implemented by classes in that package. </p>
<p>Just like the interfaces themselves, the methods defined in an interface are public no matter if you define them as so.  Please also note that you cannot define interface members (methods or variables) as private. All you can do is have them public and/or abstract. Just as a quick reminder, a constant in Java is defined as public static abstract.</p>
<p>By looking at the signature of the method someMethod, it is clear that it requires an Object  (someObject) and that it returns a result &#8211; an object. This is the contract defined by the interface.</p>
<p>Java is a complex language &#8211; defining the method as returning an object allows you to return whatever type of an object you want. You can return a String, a Collection (for instance a List) and, starting from Java 5, even a primitive like int because out of the box that primitive will be wrapped inside an Integer object and unwrapped after the call.</p>
<p>One thing you have to be careful when defining a class that implements this method is that you might be tempted to define it like this:</p>
<p>String someMethod(Integer someInteger).</p>
<p>After all someMethod expects an Object and Integer is an Object, right? Well, in Java all classes extend the Object class, so that should make sense. BUT that would brake the contract. The programmer looking at the interface contract would expect to be able to call someMethod with any object. If you were able to define someMethod expecting an Integer, that method could not possibly accept an Object because Object is not necessarely an Integer! So the answer is NO &#8211; when you implement someMethod, you have to follow the signature from the interface, as far as the arguments go. Although YOU CAN call the method with any kind of objects you want, since it just expects an object.</p>
<p>Remember, you can implement the interface by making it return the type of object specified in the signature or objects that extend it, but you have to keep the same objects in the arguments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/08/java-interface-contract/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get IP address in PHP</title>
		<link>http://www.dooriented.com/blog/2009/05/07/how-to-get-ip-address-in-php/</link>
		<comments>http://www.dooriented.com/blog/2009/05/07/how-to-get-ip-address-in-php/#comments</comments>
		<pubDate>Thu, 07 May 2009 18:02:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=35</guid>
		<description><![CDATA[Using getenv:

&#60;?php
// Example use of getenv()
$ip = getenv(&#039;REMOTE_ADDR&#039;);

// Or simply use a Superglobal ($_SERVER or $_ENV)
$ip = $_SERVER[&#039;REMOTE_ADDR&#039;];
?&#62;

Please note that the function &#8216;getenv&#8217; does not work if your Server API is ASAPI (IIS). In this case use $_SERVER["REMOTE_ADDR"].
Here is an interesting function to get the real IP address:

function getRealIpAddr()
{
if (!empty($_SERVER[&#039;HTTP_CLIENT_IP&#039;]))   //check ip from [...]]]></description>
			<content:encoded><![CDATA[<p>Using getenv:</p>
<pre class="brush: php">
&lt;?php
// Example use of getenv()
$ip = getenv(&#039;REMOTE_ADDR&#039;);

// Or simply use a Superglobal ($_SERVER or $_ENV)
$ip = $_SERVER[&#039;REMOTE_ADDR&#039;];
?&gt;
</pre>
<p>Please note that the function &#8216;getenv&#8217; does not work if your Server API is ASAPI (IIS). In this case use $_SERVER["REMOTE_ADDR"].</p>
<p>Here is an interesting function to get the real IP address:</p>
<pre class="brush: php">
function getRealIpAddr()
{
if (!empty($_SERVER[&#039;HTTP_CLIENT_IP&#039;]))   //check ip from share internet
{
$ip=$_SERVER[&#039;HTTP_CLIENT_IP&#039;];
}
elseif (!empty($_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]))   //to check ip is pass from proxy
{
$ip=$_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;];
}
else
{
$ip=$_SERVER[&#039;REMOTE_ADDR&#039;];
}
return $ip;
}
</pre>
<p>or even better</p>
<pre class="brush: php">
function getIpAddress() {
return (empty($_SERVER[&#039;HTTP_CLIENT_IP&#039;])?(empty($_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;])?
$_SERVER[&#039;REMOTE_ADDR&#039;]:$_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]):$_SERVER[&#039;HTTP_CLIENT_IP&#039;]);
}
</pre>
<p>One very important thing is that there is no way to find the IP address of a computer that&#8217;s behind the anonymous proxy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/07/how-to-get-ip-address-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Allow / Deny IP access using Apache HTTP Server</title>
		<link>http://www.dooriented.com/blog/2009/05/04/allow-deny-ip-access-using-apache-http-server/</link>
		<comments>http://www.dooriented.com/blog/2009/05/04/allow-deny-ip-access-using-apache-http-server/#comments</comments>
		<pubDate>Mon, 04 May 2009 19:31:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=23</guid>
		<description><![CDATA[In order to limit access to your application deployed on an Apache HTTP Server, you just have to edit one file : httpd.conf.
For example please take a look at the following settings :

&#60;Directory &#34;/var/www/yourapp&#34;&#62;
Options Indexes FollowSymLinks MultiViews Includes
allowOverride All
Order allow, deny
allow from 127
allow from 192.168.1.0/24
&#60;/Directory&#62;

This will allow access to &#8220;yourapp&#8221; only from localhost or from [...]]]></description>
			<content:encoded><![CDATA[<p>In order to limit access to your application deployed on an Apache HTTP Server, you just have to edit one file : httpd.conf.</p>
<p>For example please take a look at the following settings :</p>
<pre class="brush: xml">
&lt;Directory &quot;/var/www/yourapp&quot;&gt;
Options Indexes FollowSymLinks MultiViews Includes
allowOverride All
Order allow, deny
allow from 127
allow from 192.168.1.0/24
&lt;/Directory&gt;
</pre>
<p>This will allow access to &#8220;yourapp&#8221; only from localhost or from the network indicated (192.168.1.0). Please note that you don&#8217;t have to write the entire IP, Apache can figure out what&#8217;s missing. The most important rule is that what you <em><strong>don&#8217;t </strong></em>specify, Apache won&#8217;t allow. If you want to give access to some IP, you have to specify it, default is deny.</p>
<p>Take a look at the other example:</p>
<pre class="brush: xml">
&lt;Directory &quot;/var/www/yourapp&quot;&gt;
Options Indexes FollowSymLinks MultiViews Includes
allowOverride All
Order deny, allow
allow from all
deny from 123.456.(10[0-9]¦11[0-9]¦12[0-7]).
&lt;/Directory&gt;
</pre>
<p>Note that you can use regex to define the IP rule you want to implement.</p>
<p>Be careful about your allow / deny rules. The order in which you define them is very important. Apache will arrange the rules based on what you have in the &#8220;Order&#8221; clause and then treat them line by line, overriding previous rules if that&#8217;s the case!</p>
<p>For instance this<br />
allow 123.<br />
Deny 134.<br />
allow 234.<br />
allow all<br />
Deny 145<br />
if the order is Deny, allow, it will be processed as:<br />
Deny 134.<br />
Deny 145.<br />
allow 123.<br />
allow 234.<br />
allow all<br />
With allow, Deny, it will be processed as:<br />
allow 123.<br />
allow 234.<br />
allow all<br />
Deny 134.<br />
Deny 145.<br />
Also, if Apache encounters overlapping rules for the same IPs, the last rule will be implemented. For instance, in the case of an Order allow, Deny, the &#8220;allow all&#8221; rule will override the deny rules.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/04/allow-deny-ip-access-using-apache-http-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limit IP access to your web application using Apache Tomcat</title>
		<link>http://www.dooriented.com/blog/2009/05/04/limit-ip-access-to-your-web-application-using-apache-tomcat/</link>
		<comments>http://www.dooriented.com/blog/2009/05/04/limit-ip-access-to-your-web-application-using-apache-tomcat/#comments</comments>
		<pubDate>Mon, 04 May 2009 18:47:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=21</guid>
		<description><![CDATA[It is possible that you&#8217;d like to limit access to your web application from some IPs, to enhance security. If your application is deployed on Apache Tomcat, you can do that pretty darn easy &#8211; you just have to edit the server.xml file.
For example :

&#60;Engine name=&#34;Catalina&#34; defaultHost=&#34;localhost&#34;&#62;
    &#60;Host name=&#34;localhost&#34; appBase=&#34;webapps&#34;
   [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible that you&#8217;d like to limit access to your web application from some IPs, to enhance security. If your application is deployed on Apache Tomcat, you can do that pretty darn easy &#8211; you just have to edit the server.xml file.</p>
<p>For example :</p>
<pre class="brush: xml">
&lt;Engine name=&quot;Catalina&quot; defaultHost=&quot;localhost&quot;&gt;
    &lt;Host name=&quot;localhost&quot; appBase=&quot;webapps&quot;
          unpackWARs=&quot;false&quot; autoDeploy=&quot;true&quot;
          xmlValidation=&quot;false&quot; xmlNamespaceAware=&quot;false&quot;&gt;
        &lt;Valve className=&quot;org.apache.catalina.valves.AccessLogValve&quot;
                directory=&quot;c:/Program Files/Apache Software Foundation/Tomcat 6.0/logs&quot; prefix=&quot;localhost_access_log.&quot;
                suffix=&quot;.txt&quot; pattern=&quot;common&quot; resolveHosts=&quot;false&quot;/&gt;
	&lt;Valve className=&quot;org.apache.catalina.valves.RemoteAddrValve&quot;
         	allow=&quot;192.168.*.*,89.35.152.*,89.36.153.10&quot;/&gt;
    &lt;/Host&gt;
&lt;/Engine&gt;
</pre>
<p>This would limit access to the application deployed in the directory webapps in your tomcat to only the indicated IPs. Note that you can define those IPs using *.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2009/05/04/limit-ip-access-to-your-web-application-using-apache-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wicketing Javascript through AJAX</title>
		<link>http://www.dooriented.com/blog/2008/05/09/wicketing-javascript-through-ajax/</link>
		<comments>http://www.dooriented.com/blog/2008/05/09/wicketing-javascript-through-ajax/#comments</comments>
		<pubDate>Fri, 09 May 2008 17:52:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=9</guid>
		<description><![CDATA[Communication between Java and Javascript cannot be done easier than with Wicket framework, by far the best helper if you&#8217;re in Java based web development. 
html


&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.1//EN&#34; &#34;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&#34;&#62;
&#60;html xmlns:wicket&#62;
&#60;head&#62;
&#60;script type=&#34;text/javascript&#34; &#62;
function callWicket() {
	wicketAjaxGet(callback + &#039;&#38;parameter=value&#039;, function() {}, function() {});
}
&#60;/script&#62;
&#60;/head&#62;

&#60;body&#62;
	&#60;div wicket:id = &#34;div&#34;&#62;&#60;/div&#62;
	&#60;span wicket:id = &#34;wicketAnswer&#34;&#62;[]&#60;/span&#62;
&#60;/body&#62;
&#60;/html&#62;


Java &#8211; or should I say the [...]]]></description>
			<content:encoded><![CDATA[<p>Communication between Java and Javascript cannot be done easier than with Wicket framework, by far the best helper if you&#8217;re in Java based web development. </p>
<p><b>html</b></p>
<pre>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns:wicket&gt;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot; &gt;
function callWicket() {
	wicketAjaxGet(callback + &#039;&amp;parameter=value&#039;, function() {}, function() {});
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div wicket:id = &quot;div&quot;&gt;&lt;/div&gt;
	&lt;span wicket:id = &quot;wicketAnswer&quot;&gt;[]&lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</pre>
<p><b>Java &#8211; or should I say the magic of Wicket?</b></p>
<pre>
<pre class="brush: java">
package com.somepackage;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior;
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.util.time.Duration;

@SuppressWarnings(&quot;serial&quot;)
public class BasePage extends WebPage {
	private WebMarkupContainer dummyDiv;
	private Label label;

	public BasePage() {
		this(null);
	}

	public BasePage(final PageParameters parameters) {
		//handle js call to wicket
		final AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior() {
		    protected void respond(final AjaxRequestTarget target) {
		    	label.setModelObject(&quot;Yeah I was just called from Javascript!&quot;);
		        target.addComponent(label);
		    }
		};
		add(dummyDiv = new MyWebMarkupContainer(&quot;div&quot;, behavior));
		//handle wicket call to js
		dummyDiv.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)) {
			@Override
			protected void onPostProcessTarget(AjaxRequestTarget target) {
				target.appendJavascript(&quot;callWicket();&quot;);
			}
		});
		dummyDiv.add(behavior);

    	add(label = new Label(&quot;wicketAnswer&quot;, &quot;Look here to see when wicket is called from javascript&quot;));
    	label.setOutputMarkupId(true);
	}
}

@SuppressWarnings(&quot;serial&quot;)
class MyWebMarkupContainer extends WebMarkupContainer implements IHeaderContributor {
	AbstractDefaultAjaxBehavior behavior;

	public MyWebMarkupContainer(String id, AbstractDefaultAjaxBehavior behavior) {
		super(id);
		this.behavior = behavior;
	}

	@Override
	public void renderHead(IHeaderResponse response) {
		response.renderJavascript(&quot;var callback = &#039;&quot; + behavior.getCallbackUrl() + &quot;&#039;;&quot;, &quot;insertedjavascript&quot;);
	}
}
</pre>
</pre>
<p>I don&#8217;t think anyone needs explanation about how this works since it&#8217;s THAT easy. Only one more thing to add:</p>
<pre>
<pre class="brush: java">
Map map = ((WebRequestCycle) RequestCycle.get()).getRequest().getParameterMap();
</pre>
</pre>
<p>- this to get the parameters map. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2008/05/09/wicketing-javascript-through-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript inheritance</title>
		<link>http://www.dooriented.com/blog/2008/05/09/javascript-inheritance/</link>
		<comments>http://www.dooriented.com/blog/2008/05/09/javascript-inheritance/#comments</comments>
		<pubDate>Fri, 09 May 2008 17:12:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=8</guid>
		<description><![CDATA[When it comes to web development, Javascript is the best client-side programming language. It has come a long way in the last years. It&#8217;s no longer just a simple scripting language. These days a lot of Javascript libraries are available to be used freely and they are incredibly powerful: Script.aculo.us, DOJO, YUI, jQuery, Prototype, to [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to web development, Javascript is the best client-side programming language. It has come a long way in the last years. It&#8217;s no longer just a simple scripting language. These days a lot of Javascript libraries are available to be used freely and they are incredibly powerful: Script.aculo.us, DOJO, YUI, jQuery, Prototype, to name just a few. </p>
<p>I am personally not very found of Javascript because of its loosely typed nature. I consider it harder to develop a large framework in Javascript compared to say, Java, because the compiler/interpreter cannot  always come to your rescue as you&#8217;d expect if you&#8217;re coming from a strongly typed language. </p>
<p>But a lot of its strength comes from the fact that it&#8217;s loosely typed. You also feel the sense of freedom that only these kind of languages (like Ruby) can offer. Types help you a lot to avoid errors and to give you important structure, but also constrain your ability to do more with your code. </p>
<p>Javascript is (or can act like) a(n almost) full fledged object oriented language. Let&#8217;s try inheritance:</p>
<p>This is the method that simulates inheritance in Javascript:</p>
<pre>
<pre class="brush: javascript">
function inherit(child, parent) {
    var sConstructor = parent.toString();
    var aMatch = sConstructor.match( /\s*function (.*)\(/ );
    if ( aMatch != null ) { child.prototype[aMatch[1]] = parent; }
    for (var m in parent.prototype) {
        child.prototype[m] = parent.prototype[m];
    }
};
</pre>
</pre>
<p>Let&#8217;s define some Javascript objects:</p>
<pre>
<pre class="brush: javascript">
function Element() {
	this.location = null;
	this.type = &quot;Element&quot;;
	this.selected = false;
	this.zIndex = 0;
}
Element.prototype.isInside = function(rectangle){
        dosomething;
}

function Item() {
	this.Element(); //calling the constructor of the base class

	this.lastValidLocation = null; //a rectangle
	this.type = &quot;Item&quot;;
	this.selectorItem = null;
	this.zIndex = 1;
}
inherit(Item, Element);
Item.prototype.getSelectorItem = function() {
	return this.selectorItem;
}
Item.prototype.draw = function() {
       dosomething;
}
Item.prototype.deleteItem = function() {
       dosomething;
}

function SelectorItem() {
	this.Element();

	this.items = new Array();
	this.type = &quot;SelectorItem&quot;;
	this.zIndex = 0;
}
inherit(SelectorItem, Element);
SelectorItem.prototype.getSelectorItem = function() {
	return this;
}
SelectorItem.prototype.createNewItem = function(onItem) {
       dosomething;
}
SelectorItem.prototype.draw = function() {
       dosomething;
}
</pre>
</pre>
<p>It is <b>very important</b> when you call &#8220;inherit&#8221;. That&#8217;s because Javascript does not support method override/overload, but you can also simulate this. When executing &#8220;inherit&#8221;, the prototype of the base class will be copied to the child. Then, if needed, redefine some methods so that when you call them, the new ones will get executed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2008/05/09/javascript-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a static image map with Wicket</title>
		<link>http://www.dooriented.com/blog/2008/05/09/using-a-static-image-map-with-wicket/</link>
		<comments>http://www.dooriented.com/blog/2008/05/09/using-a-static-image-map-with-wicket/#comments</comments>
		<pubDate>Fri, 09 May 2008 16:20:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://www.dooriented.com/blog/?p=7</guid>
		<description><![CDATA[On one of my projects I had to implement an image and link the image area to wicket.
This is how I did it:
html


&#60;div&#62;
   &#60;map name=&#34;themap&#34;&#62;
       &#60;area shape=&#34;rect&#34; coords=&#34;a1,b1,c1,d1&#34; href=&#34;#&#34;
           wicket:id=&#34;wicket1&#34; title=&#34;Title1&#34; /&#62;
      [...]]]></description>
			<content:encoded><![CDATA[<p>On one of my projects I had to implement an image and link the image area to wicket.</p>
<p>This is how I did it:</p>
<p><b>html</b></p>
<pre>
<pre class="brush: html">
&lt;div&gt;
   &lt;map name=&quot;themap&quot;&gt;
       &lt;area shape=&quot;rect&quot; coords=&quot;a1,b1,c1,d1&quot; href=&quot;#&quot;
           wicket:id=&quot;wicket1&quot; title=&quot;Title1&quot; /&gt;
       &lt;area shape=&quot;rect&quot; coords=&quot;a2,b2,c2,d2&quot; href=&quot;#&quot;
           wicket:id=&quot;wicket2&quot; title=&quot;Title2&quot; /&gt;
   &lt;/map&gt;
   &lt;br/&gt;
   Some text here
&lt;/div&gt;
</pre>
</pre>
<p><b>Java</b></p>
<pre>
<pre class="brush: html">
       add(new PageLink(&quot;wicket1&quot;, SomeWicketClass1.class));
       add(new PageLink(&quot;wicket2&quot;, SomeWicketClass2.class));
</pre>
</pre>
<p>Wicket is the best framework for web development. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dooriented.com/blog/2008/05/09/using-a-static-image-map-with-wicket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
