<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>webprogramming &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/webprogramming/</link>
	<description>Feed of posts on WordPress.com tagged "webprogramming"</description>
	<pubDate>Sat, 19 Jul 2008 04:52:21 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[JBO-35007: Row currency has changed error fixes]]></title>
<link>http://oldlight.wordpress.com/?p=25</link>
<pubDate>Fri, 18 Jul 2008 04:58:58 +0000</pubDate>
<dc:creator>oldlight</dc:creator>
<guid>http://oldlight.wordpress.com/?p=25</guid>
<description><![CDATA[When developing JSF pages using Oracle ADF Faces 10.1.3.3, I encountered the error that is reported ]]></description>
<content:encoded><![CDATA[<p><strong>When developing JSF pages using Oracle ADF Faces 10.1.3.3, I encountered the error that is reported at the top of the page as: JBO-35007 indicated that the row currency has changed since last visit or something. This was so annoy that it is repeatedly occurred everytimes I hit the back button. Sometimes it disappear when I press Refresh.</strong><br />
Googling around, I found two working solutions for the error:</p>
<ul>
<li><a href="http://satishshelake.blogspot.com/2007/10/jbo-35007-row-currency-has-changed.html">http://satishshelake.blogspot.com/2007/10/jbo-35007-row-currency-has-changed.html</a></li>
</ul>
<p style="padding-left:30px;">1.Go to page definition of jsp or jspx by right click on page.<br />
2.Select Iterator of page by using structure window or definition page<br />
3.Go to the Inspector window and change the StateValidation property as false.</p>
<ul>
<li><a href="http://www.google.com.vn/url?sa=t&#38;ct=res&#38;cd=1&#38;url=http%3A%2F%2Fone-size-doesnt-fit-all.blogspot.com%2F2007%2F01%2Fbah-what-is-jbo-35007.html&#38;ei=vRGASIXqPIiy6gOd9JzXBw&#38;usg=AFQjCNEfnPPInbXYwiFiQ4Wzz9ENf_A1Tw&#38;sig2=4pXkJn3qrV5GGgPqLeRdrQ" target="_blank">http://www.google.com.vn/url?sa=t&#38;ct=res&#38;cd=1&#38;url=http%3A%2F%2Fone-size-doesnt-fit-all.blogspot.com%2F2007%2F01%2Fbah-what-is-jbo-35007.html&#38;ei=vRGASIXqPIiy6gOd9JzXBw&#38;usg=AFQjCNEfnPPInbXYwiFiQ4Wzz9ENf_A1Tw&#38;sig2=4pXkJn3qrV5GGgPqLeRdrQ</a></li>
</ul>
<p style="padding-left:30px;">"And as can be seen from the JDev doco note, the row currency token mechanism can be turned off per page through the pageDef for your page, setting the <span style="font-family:courier new;"><strong>EnableTokenValidation</strong> </span>to false.<span> </span>(Be warned you should not flippantly turn this off for pages, or blanket turn it off for all pages, as the mechanism is an important one)</p>
<p>So enjoy your programming...</p>
<p>Minh-Tran</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Podcast Episode 6: Aggregating the Social Web with the FriendFeed API]]></title>
<link>http://vanturtle.wordpress.com/?p=90</link>
<pubDate>Fri, 30 May 2008 03:48:37 +0000</pubDate>
<dc:creator>Van Turtle</dc:creator>
<guid>http://vanturtle.wordpress.com/?p=90</guid>
<description><![CDATA[Subscribe to &quot;Work That Web&quot; at iTunes
at Podcast Alley | at Mevio
Feed: http://feeds.feed]]></description>
<content:encoded><![CDATA[<h3><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=278065971">Subscribe to &#34;Work That Web&#34; at iTunes</a></h3>
<p><a href="http://www.podcastalley.com/podcast_details.php?pod_id=56009">at Podcast Alley</a> &#124; <a href="http://music.podshow.com/music/listeners/podshow_details.php?ShowHash=192a68e88083af749e0c1568ddd96c67">at Mevio</a><br />
Feed: <a href="http://feeds.feedburner.com/vanturtlepodcast">http://feeds.feedburner.com/vanturtlepodcast</a></p>
<hr />
<div align="left">Welcome to &#8220;<a href="http://www.workthatweb.com">Work That Web</a> &#8221;, the weekly web developer podcast.&#160; This is <a href="http://www.davidvanvickle.com/">david@podturtle.com</a> .&#160; This is &#8220;Episode 6: Aggregating the Social Web with the <a href="http://friendfeed.com/api/">FriendFeed API</a> &#8221;.</p>
<p>  First off, let&#8217;s define aggregation as taking a bunch of things and putting them all in one place.</p>
<p>  Let&#8217;s try something.&#160; I&#8217;m going to read off a bunch of web services.&#160; Which ones are you a member of?</p>
<ul>
<li>Digg</li>
<li>Google Reader</li>
<li>Google Talk</li>
<li>Gmail</li>
<li>Mixx</li>
<li>Reddit</li>
<li>del.icio.us</li>
<li>Furl</li>
<li>Ma.gnolia</li>
<li>StumbleUpon</li>
<li>Jaiku</li>
<li>Pownce</li>
<li>Twitter</li>
<li>Seesmic</li>
<li>Vimeo</li>
<li>YouTube</li>
<li>Flickr</li>
<li>Picasa</li>
<li>SmugMug</li>
<li>Zooomr</li>
<li>Tumblr</li>
<li>iLike</li>
<li>Last.fm</li>
<li>Pandora</li>
<li>Goodreads</li>
<li>LibraryThing</li>
<li>Amazon</li>
<li>Disqus</li>
<li>LinkedIn</li>
<li>Netflix Queue</li>
<li>Netvibes</li>
<li>SlideShare</li>
<li>Upcoming</li>
<li>Yelp</li>
<li>or any blog</li>
<li>or anything else putting off an RSS feed</li>
</ul>
<p>
  Each of these can be pulled into one feed by <a href="http://www.friendfeed.com">FriendFeed.com</a> .</p>
<p>  How many of those services are you a member of?&#160; What do you do when you want visitors to see all your posts in one place?&#160; Think about using <a href="http://www.friendfeed.com">FriendFeed</a> and harnessing it&#8217;s <a href="http://friendfeed.com/api/">API</a> .&#160; We&#8217;ll use it to create a single central feed out of the chaos.</p>
<p>  So how does <a href="http://www.friendfeed.com">FriendFeed</a> work?&#160; Each member loads up their various accounts from around the web - <a href="http://www.google.com/reader">Google Reader</a> shared articles, <a href="http://www.twitter.com">Twitter</a> posts, blog entries, <a href="http://www.youtube.com">YouTube</a> videos, <a href="http://www.flickr.com">Flickr</a> photos, <a href="http://del.icio.us/">del.icio.us</a> bookmarks, all that stuff I listed earlier - and members can have discussions around each entry.&#160; It&#8217;s a furious stream of information and comments coming from all directions. blogs, news, pictures, etc - all flying by, with comments.&#160; It&#8217;s the daily web posting activity of thousands of people in one place.</p>
<p>  <a href="http://www.facebook.com">Facebook</a> already has a nice <a href="http://apps.facebook.com/friendfeed/?ref=ts">FriendFeed app</a> so your friends can see your <a href="http://www.friendfeed.com">FriendFeed</a>-aggregated posts.</p>
<p>  Otherwise showing it on another web page (like a very cool business&#8217; web page) means we&#8217;re off to the FriendFeed API.</p>
<p>  First thing we need is a <a href="http://www.friendfeed.com">FriendFeed</a> account.&#160; They&#8217;re free.&#160; Go to <a href="http://www.friendfeed.com">friendfeed.com</a> and follow the instructions. </p>
<p>  Then load all of your web memberships into <a href="http://www.friendfeed.com">FriendFeed</a> so you&#8217;ll have stuff in your feed.</p>
<p>  Then we need to download the API from <a href="http://code.google.com/p/friendfeed-api/">http://code.google.com/p/friendfeed-api/</a> .&#160; Documentation and forums are available at <a href="http://friendfeed.com/api/">http://friendfeed.com/api/</a> .</p>
<p>  Then, in order to authenticate with the API, we get our new account&#8217;s Remote Key from <a href="http://friendfeed.com/remotekey">http://friendfeed.com/remotekey</a> .</p>
<p>  That&#8217;s all the official <a href="http://www.friendfeed.com">FriendFeed</a> stuff we need.&#160; Now on to our application.&#160; I called it FriendFeedFormatter.</p>
<p>  It is not affiliated with <a href="http://www.friendfeed.com">FriendFeed</a>.&#160; Use it all at your own risk. FriendFeed has stated that the API is young and could change at any time.&#160; That disclaimer out of the way...</p>
<p>  My code does all the work of taking our nickname and remote key and producing an HTML snippet from our FriendFeed feed that we can then have included in a PHP page.&#160; Download example.zip from the show notes.&#160; It&#8217;s got all the code that I&#8217;ve written using the API.</p>
<p>  <a href="http://www.davidvanvickle.com/friendfeed/example.zip">http://www.davidvanvickle.com/friendfeed/example.zip</a> </p>
<p>  In the show notes is a link to see sample output.&#160; That will give you an idea of what to expect, and you can begin to think of how to embellish it.</p>
<p>  <a href="http://www.davidvanvickle.com/friendfeed/build.php">http://www.davidvanvickle.com/friendfeed/build.php</a> </p>
<p>  There are only two files in example.zip.&#160; One is my FriendFeedFormatter PHP class.&#160; The other is build.php, which is the file you&#8217;ll customize and run.</p>
<p>  Now find the <a href="http://friendfeed.com/api/">FriendFeed API</a> you downloaded.&#160; In order for my custom class to work, you&#8217;ll need to include the friendfeed.php file from the API in the same folder.</p>
<p>  So when you&#8217;re done there will be 3 files uploaded to a folder on your PHP enabled web server.&#160; friendfeed.php from the API, plus FriendFeedFormatter.php and build.php.</p>
<p>  Before we try to run anything we need to change a couple things inside of build.php.&#160; So open that file in a text editor.</p>
<p>  Enter your FriendFeed nickname where it says &#8220;MY_NICKNAME&#8221;.&#160; Then enter your remote key where it says &#8220;MY_REMOTEKEY&#8221;.&#160; That&#8217;s it.&#160; There are more things we could toggle but let&#8217;s start here.</p>
<p>  So save and close build.php and upload the 3 files to the web server.&#160; Now you should be able to hit your build.php with a web browser and see what happens.</p>
<p>  If all is well then you&#8217;ll see the HTML table that the FriendFeedFormatter produced using the API.&#160; Now look in the webserver folder where you uploaded the 3 files.&#160; You should now see a 4th file.&#160; That file is what you&#8217;ll be including in your normal web pages.&#160; It is JUST the HTML table displaying your feed.&#160; Just a little piece of a web page, not the whole thing.&#160; Perfect for inserting into a page that already exists.</p>
<p>  Why don&#8217;t I just write a Javascript snippet like everyone else?&#160; Well because I don&#8217;t want to slow my web pages with a call to a remote site.&#160; The FriendFeed servers are pretty fast, but I still don&#8217;t want that dependancy if I can help it.&#160; As long as I can run that build.php file on a regular basis, I will have a new enough include file for my site.&#160; And it will load right away.</p>
<p>  So how do I run build.php on a regular basis?&#160; Good question.&#160; If you want to automate that, I have half an answer.&#160; If you&#8217;re familiar with running cron jobs, or if you want to learn how, cron would be a good way.&#160; Cron allows your server to perform a task - such as calling build.php - according to a schedule, like every few minutes, instead of waiting for a web user to come along and trigger it.&#160; Cron is usually running already.&#160; You don&#8217;t have to install it.&#160; Just add a crontab to call lynx, wget, or on older servers, the php cgi executable and pass it build.php and how often it should run.</p>
<p>  Truth be told, I don&#8217;t have much experience with cron, but it seems to be where people go for scheduling scripts.&#160; I included some examples in the show notes that I scraped from the web to get you started.&#160; I&#8217;m sorry that I don&#8217;t have more tested examples.</p>
<p>  Run every Monday morning at 4:41AM.&#160; (minute hour day month weekday command)</p>
<p>  41 04 * * 1 /path/to/lynx http://www.mydomain.com/path/to/your/cron.php<br />
  or<br />
  41 04 * * 1 /path/to/wget http://www.mydomain.com/path/to/your/cron.php<br />
  or<br />
  41 04 * * 1 /path/to/php /path/to/your/cron.php</p>
<p>  Samples from:<br />
  <a href="http://www.hackernotcracker.com/2007-04/run-php-scripts-with-crond-and-crontab.html">http://www.hackernotcracker.com/2007-04/run-php-scripts-with-crond-and-crontab.html</a> <br />
  <a href="http://www.modwest.com/help/kb.phtml?cat=2&#38;qid=105">http://www.modwest.com/help/kb.phtml?cat=2&#38;qid=105</a> </p>
<p>  More at<br />
  <a href="http://www.webmasterworld.com/forum40/1258.htm">http://www.webmasterworld.com/forum40/1258.htm</a> </p>
<p>  Otherwise just keep build.php bookmarked and hit it every time you do something that updates your feed.</p>
<p>  Fortunately for server performance, but unfortunate for us, is that <a href="http://www.friendfeed.com">FriendFeed</a> is on it&#8217;s own schedule.&#160; Just because I update my blog, doesn&#8217;t mean <a href="http://www.friendfeed.com">FriendFeed</a> is immediately aware of that post.&#160; It may take a few minutes for it to show up in the <a href="http://www.friendfeed.com">FriendFeed</a> feed.&#160; (That&#8217;s a great reason to figure out how to make the cron way work)</p>
<p>  The code to pull in the include file in your PHP page is the same code in build.php that displays the output in the browser.&#160; The FriendFeedFormatter-&#62;get_output() method.</p>
<p>  Once you see the output, I&#8217;m sure you&#8217;ll want to customize it more.&#160; Go for it.</p>
<p>  I built in a few enhancements.</p>
<p>  One enhancement is date formatting.&#160; The date may come to you a couple different ways.&#160; One is in ISO8601 format.&#160; That looks like this. &#8220;2008-05-21T15:02:22Z&#8221; </p>
<p>  Another format would be as a UNIX timestamp, or a long number that represents the number of seconds since January 1, 1970.</p>
<p>  You should be able to look in the date column, see which kind of date you have, and change the value of the date format variable in build.php.</p>
<p>  $ff_date_format = &#8216; ISO8601&#8217;; // or &#8216;unix&#8217;</p></div>
<div align="left">
  On one server I got one format, on another I got the other format.&#160; I think that&#8217;s based on the PHP version I had running but I&#8217;m not sure.&#160; Anyway, that&#8217;s why my code has two ways to format dates.</p>
<p>  Another customization is the title of the table.&#160; I recommend making that a link to your <a href="http://www.friendfeed.com">Friendfeed</a> page.&#160; The current set up has a link to your FF page, plus a link to&#160; subscribe to your feed.</p>
<p>  The formatter has a couple features users may appreciate.&#160; One is inline <a href="http://www.youtube.com">Youtube</a> videos.&#160; First the user sees a JPG image of the video, but when it is clicked, it turns into a playable video.</p>
<p>  Another feature is link detection, which is programmed to happen with <a href="http://www.twitter.com">Twitter</a> entries.&#160; The static URL&#8217;s become clickable.</p>
<p>  The last feature is, when <a href="http://www.flickr.com">Flickr</a> is detected, it lists the thumbnails of the images.</p>
<p>  These are things I expected to happen from the API, but they weren&#8217;t there, so I added them to my formatter.</p>
<p>  Open the formatter and notice how I can treat each service&#8217;s entries differently.&#160; I can detect <a href="http://www.twitter.com">Twitter</a>, for instance, and scan the entry for URL&#8217;s to convert into links.&#160; Or I can detect <a href="http://www.youtube.com">Youtube</a> and make the inline play feature happen.</p>
<p>  The important thing is just to hack away to get going using <a href="http://www.friendfeed.com">FriendFeed</a> to aggregate your public web activity.</p>
<p>
  The music was by &#8220;<a href="http://www.myspace.com/thehorseyourodeinonusa">The Horse You Rode In On</a> &#8221;.&#160; They&#8217;re at <a href="http://www.myspace.com/thehorseyourodeinonusa">myspace.com/thehorseyourodeinonusa</a> .&#160; Some of the music provided tonight from the PodShow Podsafe Music Network. Check it out at<a href="http://music.podshow.com"> music.podshow.com</a> .</p>
<p>  <a href="http://www.myspace.com/thehorseyourodeinonusa">http://www.myspace.com/thehorseyourodeinonusa</a> <br />
  <a href="http://music.podshow.com">http://music.podshow.com</a> </p>
<p>  If you get a chance please visit podturtle.com.&#160; It&#8217;s now possible to post comments under the show notes.&#160; Until next week, this is <a href="http://www.davidvanvickle.com/">David</a> saying &#34;<a href="http://www.workthatweb.com">work that web</a> !&#34;.</div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Web Services]]></title>
<link>http://webcareanddesign.wordpress.com/?p=3</link>
<pubDate>Tue, 13 May 2008 11:21:36 +0000</pubDate>
<dc:creator>webcareanddesign</dc:creator>
<guid>http://webcareanddesign.wordpress.com/?p=3</guid>
<description><![CDATA[As a matter of fact you can find innumerable companies who assure to provide professional web based ]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&#34;"><span style="font-size:small;">As a matter of fact you can find innumerable companies who assure to provide professional web based </span><a href="http://webcareanddesign.com/services.html"><span style="text-decoration:none;"><span style="font-size:small;">solutions</span></span></a><span style="font-size:small;">. But, it hardly happens that all of them are able to perform accordingly. We are surely one of them who do not come out with sheer failure. It is a pleasure in saying that Web Care &#38; Design is well organized and equipped to handle any and every project in the fields of Web Designing, HTML/CSS, Programming, Administrative Support and SEO.</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:11pt;line-height:115%;font-family:&#34;">At <a href="http://webcareanddesign.com/"><span style="text-decoration:none;">Web Care &#38; Design</span></a> we strive to gratify our customers with unparalleled service in the domain of Web Designing, HTML/CSS, Programming, Administrative Support and SEO. Our skilled employees put substantial effort to give a productive outcome in each and every domain that we are into. At Web Care &#38; Design our chief motto is to offer reliable service through which the customers can acquire a great experience. We help you to succeed more and more in your business with our solutions.</span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Usability in web 2.0 application.]]></title>
<link>http://huberrtt.wordpress.com/?p=7</link>
<pubDate>Sat, 26 Apr 2008 13:05:48 +0000</pubDate>
<dc:creator>mikwiat</dc:creator>
<guid>http://huberrtt.wordpress.com/?p=7</guid>
<description><![CDATA[Projekt zwiazany ze stworzeniem witryny www, ktorej najwiekszym atutem byloby &#8220;usability]]></description>
<content:encoded><![CDATA[<p>Projekt zwiazany ze stworzeniem witryny www, ktorej najwiekszym atutem byloby "usability" w pelnym znaczeniu tego slowa okazal sie nie tak latwy do wykonania jakby komus mogloby sie zdawac.</p>
<p>Czy menu jest w dobrym miejscu? Czy feedback przy rejestracji / logowaniu, lub nie poprawnej rejestracji / niepoprawnym loginie jest widoczny? Czy okienko powinno zniknac po 2 sekundach, a moze po 2,2 sekundach?</p>
<p>To pytanie zadaje sobie w kolko.</p>
<p>Czy zawsze uzytkownik musi miec feedback, czy tak naprawde czytamy wiadomosci systemowe, ostrzegajace Nas przed roznymi "niebezpieczenstwami" na stronie www i ktory kolor przyciaga Nasza uwage w jak najlepszy sposob, a ktory nie przyciaga jej w ogole?</p>
<p>Na te, oraz setke innych pytan postaram sie sobie sam odpowiedziec w przeciagu nastepnych paru tygodni.</p>
<p>Feel free to join our discussion, about that, and much more.</p>
<p><em><span style="color:#ff289c;">//mikwiat</span></em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Howto deploy a ADFBC app developed to Tomcat6.0.14 and MySQL 5.0]]></title>
<link>http://oldlight.wordpress.com/?p=21</link>
<pubDate>Tue, 22 Apr 2008 11:07:16 +0000</pubDate>
<dc:creator>oldlight</dc:creator>
<guid>http://oldlight.wordpress.com/?p=21</guid>
<description><![CDATA[Source: OTN JDeveloper Forum
All
Just successfully deployed a JSF/ADF-BC4J app developed in Jdev 10.]]></description>
<content:encoded><![CDATA[<p>Source: <a href="http://forums.oracle.com/forums/thread.jspa?threadID=645851&#38;tstart=0" target="_blank">OTN JDeveloper Forum</a></p>
<p>All</p>
<p>Just successfully deployed a JSF/ADF-BC4J app developed in Jdev 10.1.3.3 to Tomcat-6.0.14 and MySQL 5.0</p>
<p>Thought I would share since i could not find anything out there that gave me the steps for this configuration combo.</p>
<p>Assumptions:<br />
1. install MySQL 5.0 database with some tables.<br />
2. install Tomcat-6.0.14 (<a href="http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.14/bin/">http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.14/bin/</a>) probably any 6.x build would be same<br />
3. Application Modules developed in Jdev are currently configured to run on MySQL (SQL92 flavor / Java type mappings)<br />
4. This is for ADF-BC4J only. TopLink would require add'l steps, though I assume the only difference would be add'l jar files</p>
<p>I did all development in Jdev using the internal OC4J and a local MySQL before deploying to Tomcat.</p>
<p>Steps:<br />
1. copy following jars from &#60;JDEV_INSTALL&#62; to &#60;TOMCAT_HOME&#62;\lib\<br />
(Note that 'Tools -&#62; ADF Runtime Installer' does not work for Tomcat 6.x, so this has to be manual)</p>
<p>\BC4J\lib\adfcm.jar<br />
\BC4J\lib\adfm.jar<br />
\BC4J\lib\adfmweb.jar<br />
\BC4J\lib\adfshare.jar<br />
\BC4J\lib\bc4jct.jar<br />
\BC4J\lib\bc4jctejb.jar<br />
\BC4J\lib\bc4jdomorcl.jar<br />
\BC4J\lib\bc4jimdomains.jar<br />
\BC4J\lib\bc4jmt.jar<br />
\BC4J\lib\bc4jmtejb.jar<br />
\BC4J\lib\collections.jar<br />
\BC4J\jlib\bc4jdomgnrc.jar<br />
\BC4J\jlib\adfmtl.jar<br />
\BC4J\jlib\adfui.jar<br />
\jlib\commons-cli-1.0.jar<br />
\jlib\xmlef.jar<br />
\jlib\share.jar<br />
\mds\lib\mdsrt.jar<br />
\mds\lib\concurrent.jar<br />
\diagnostics\lib\ojdl.jar<br />
\jlib\jdev-cm.jar<br />
\jlib\commons-el.jar<br />
\jlib\oracle-el.jar<br />
\jlib\jsp-el-api.jar<br />
\toplink\jlib\toplink.jar<br />
\toplink\jlib\antlr.jar<br />
\BC4J\lib\adfbinding.jar<br />
\lib\xmlparserv2.jar<br />
\lib\xml.jar<br />
\lib\xsqlserializers.jar<br />
\lib\xsu12.jar<br />
\ord\jlib\ordhttp.jar<br />
\ord\jlib\ordim.jar<br />
\sqlj\lib\runtime12.jar<br />
\sqlj\lib\translator.jar<br />
\jdbc\lib\ojdbc14.jar<br />
\jdbc\lib\ojdbc14dms.jar<br />
\lib\dms.jar<br />
\javacache\lib\cache.jar<br />
\BC4J\jlib\dc-adapters.jar<br />
\BC4J\jlib\adf-connections.jar<br />
\webservices\lib\wsdl.jar<br />
\webservices\lib\orajaxr.jar<br />
\webservices\lib\orawsrm.jar<br />
\webservices\lib\wsclient.jar<br />
\webservices\lib\orasaaj.jar<br />
\webservices\lib\xsdlib.jar<br />
\webservices\lib\mdds.jar<br />
\webservices\lib\wssecurity.jar<br />
\webservices\lib\orawsdl.jar<br />
\jlib\osdt_core.jar<br />
\jlib\osdt_cert.jar<br />
\jlib\osdt_xmlsec.jar<br />
\jlib\osdt_wss.jar<br />
\jlib\osdt_saml.jar<br />
\jlib\ojpse.jar<br />
\jlib\oraclepki.jar<br />
\j2ee\home\jazncore.jar<br />
\j2ee\home\lib\http_client.jar</p>
<p>2. copy &#60;JDEV_INSTALL&#62;\BC4J\redist\webapp.war to &#60;TOMCAT_HOME&#62;\webapps\webapp.war</p>
<p>3. in your application's webroot, create a META-INF folder containing a single file, named 'context.xml', with the following (enter your appropriate values as usual):</p>
<p>&#60;?xml version="1.0" encoding="UTF-8"?&#62;<br />
&#60;Context<br />
antiJARLocking="true"<br />
antiResourceLocking="true"<br />
reloadable="true"&#62;<br />
&#60;Resource<br />
auth="Container"<br />
name="jdbc/MySqlDS"<br />
type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"<br />
factory="com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory"<br />
driverClassName="com.mysql.jdbc.Driver"<br />
maxIdle="2"<br />
maxWait="5000"<br />
url="jdbc:mysql://&#60;HOSTNAME&#62;:&#60;PORT&#62;/&#60;DATABASE&#62;?&#38;ultraDevHack=true&#38;capitalizeTypeNames=true&#38;pedantic=true"<br />
user="&#60;USERNAME&#62;"<br />
password="&#60;PASSWORD&#62;"<br />
databaseName="&#60;DATABASE&#62;"<br />
port="&#60;PORT&#62;"<br />
maxActive="10"/&#62;<br />
&#60;Manager<br />
className="org.apache.catalina.session.PersistentManager"<br />
saveOnRestart="false"/&#62;<br />
&#60;/Context&#62;</p>
<p>4. in all Application Modules, set the Configuration to use a 'JDBC Datasource' with the name set to the named datasource in the context.xml created above, e.g.: 'java:comp/env/jdbc/MySqlDS'</p>
<p>5. create a deployment profile with 'Platform -&#62; target connection' set to the Tomcat instance (need to create an entry in 'Connections -&#62; Application Server' for it to show up) make sure to include the correct mysql-connector.jar in the 'WEB-INF/lib' contributors.<br />
Right-click -&#62; Deploy to your tomcat</p>
<p>6. Make sure MySQL is on and fire up Tomcat, and youre set.</p>
<p>Hope it helps<br />
Sami</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Apache POI - HSSF API - làm việc với microsoft office]]></title>
<link>http://oldlight.wordpress.com/?p=19</link>
<pubDate>Tue, 22 Apr 2008 04:07:32 +0000</pubDate>
<dc:creator>oldlight</dc:creator>
<guid>http://oldlight.wordpress.com/?p=19</guid>
<description><![CDATA[
HWPFF là một thành phần của bộ thư viện Apache POI cho phép bạn tương tác với ]]></description>
<content:encoded><![CDATA[<p><font face="Verdana"><br />
HWPFF là một thành phần của bộ thư viện Apache POI cho phép bạn tương tác với Microsoft Exel sử dụng ngôn ngữ Java. Các tính năng chủ yếu của Apache POI bao gồm:</p>
<p><strong> Tạo mới một workbook</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Tạo mới một sheet</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet1 = wb.createSheet("new sheet");<br />
HSSFSheet sheet2 = wb.createSheet("second sheet");<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Tạo cell</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");<br />
// Create a row and put some cells in it. Rows are 0 based.<br />
HSSFRow row = sheet.createRow((short)0);<br />
// Create a cell and put a value in it.<br />
HSSFCell cell = row.createCell((short)0);<br />
cell.setCellValue(1);</p>
<p>// Or do it on one line.<br />
row.createCell((short)1).setCellValue(1.2);<br />
row.createCell((short)2).setCellValue("This is a string");<br />
row.createCell((short)3).setCellValue(true);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Tạo cell với giá trị là ngày tháng</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");</p>
<p>// Create a row and put some cells in it. Rows are 0 based.<br />
HSSFRow row = sheet.createRow((short)0);</p>
<p>// Create a cell and put a date value in it.  The first cell is not styled<br />
// as a date.<br />
HSSFCell cell = row.createCell((short)0);<br />
cell.setCellValue(new Date());</p>
<p>// we style the second cell as a date (and time).  It is important to<br />
// create a new cell style from the workbook otherwise you can end up<br />
// modifying the built in style and effecting not only this cell but other cells.<br />
HSSFCellStyle cellStyle = wb.createCellStyle();<br />
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));<br />
cell = row.createCell((short)1);<br />
cell.setCellValue(new Date());<br />
cell.setCellStyle(cellStyle);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Làm việc với nhiều loại cell</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");<br />
HSSFRow row = sheet.createRow((short)2);<br />
row.createCell((short) 0).setCellValue(1.1);<br />
row.createCell((short) 1).setCellValue(new Date());<br />
row.createCell((short) 2).setCellValue("a string");<br />
row.createCell((short) 3).setCellValue(true);<br />
row.createCell((short) 4).setCellType(HSSFCell.CELL_TYPE_ERROR);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Điều chỉnh cell</strong></p>
<p><code>public static void main(String[] args)<br />
throws IOException<br />
{<br />
HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");<br />
HSSFRow row = sheet.createRow((short) 2);<br />
createCell(wb, row, (short) 0, HSSFCellStyle.ALIGN_CENTER);<br />
createCell(wb, row, (short) 1, HSSFCellStyle.ALIGN_CENTER_SELECTION);<br />
createCell(wb, row, (short) 2, HSSFCellStyle.ALIGN_FILL);<br />
createCell(wb, row, (short) 3, HSSFCellStyle.ALIGN_GENERAL);<br />
createCell(wb, row, (short) 4, HSSFCellStyle.ALIGN_JUSTIFY);<br />
createCell(wb, row, (short) 5, HSSFCellStyle.ALIGN_LEFT);<br />
createCell(wb, row, (short) 6, HSSFCellStyle.ALIGN_RIGHT);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</p>
<p>}</p>
<p>/**<br />
* Creates a cell and aligns it a certain way.<br />
*<br />
* @param wb        the workbook<br />
* @param row       the row to create the cell in<br />
* @param column    the column number to create the cell in<br />
* @param align     the alignment for the cell.<br />
*/<br />
private static void createCell(HSSFWorkbook wb, HSSFRow row, short column, short align)<br />
{<br />
HSSFCell cell = row.createCell(column);<br />
cell.setCellValue("Align It");<br />
HSSFCellStyle cellStyle = wb.createCellStyle();<br />
cellStyle.setAlignment(align);</p>
<p>cell.setCellStyle(cellStyle);<br />
}</code><br />
<strong><br />
Làm việc với border</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");</p>
<p>// Create a row and put some cells in it. Rows are 0 based.<br />
HSSFRow row = sheet.createRow((short) 1);</p>
<p>// Create a cell and put a value in it.<br />
HSSFCell cell = row.createCell((short) 1);<br />
cell.setCellValue(4);</p>
<p>// Style the cell with borders all around.<br />
HSSFCellStyle style = wb.createCellStyle();<br />
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);<br />
style.setBottomBorderColor(HSSFColor.BLACK.index);<br />
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);<br />
style.setLeftBorderColor(HSSFColor.GREEN.index);<br />
style.setBorderRight(HSSFCellStyle.BORDER_THIN);<br />
style.setRightBorderColor(HSSFColor.BLUE.index);<br />
style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED);<br />
style.setTopBorderColor(HSSFColor.BLACK.index);<br />
cell.setCellStyle(style);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Tô màu và màu sắc</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");</p>
<p>// Create a row and put some cells in it. Rows are 0 based.<br />
HSSFRow row = sheet.createRow((short) 1);</p>
<p>// Aqua background<br />
HSSFCellStyle style = wb.createCellStyle();<br />
style.setFillBackgroundColor(HSSFColor.AQUA.index);<br />
style.setFillPattern(HSSFCellStyle.BIG_SPOTS);<br />
HSSFCell cell = row.createCell((short) 1);<br />
cell.setCellValue("X");<br />
cell.setCellStyle(style);</p>
<p>// Orange "foreground", foreground being the fill foreground not the font color.<br />
style = wb.createCellStyle();<br />
style.setFillForegroundColor(HSSFColor.ORANGE.index);<br />
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);<br />
cell = row.createCell((short) 2);<br />
cell.setCellValue("X");<br />
cell.setCellStyle(style);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Trộn dòng, cột</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");</p>
<p>HSSFRow row = sheet.createRow((short) 1);<br />
HSSFCell cell = row.createCell((short) 1);<br />
cell.setCellValue("This is a test of merging");</p>
<p>sheet.addMergedRegion(new Region(1,(short)1,1,(short)2));</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Làm việc với font</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");</p>
<p>// Create a row and put some cells in it. Rows are 0 based.<br />
HSSFRow row = sheet.createRow((short) 1);</p>
<p>// Create a new font and alter it.<br />
HSSFFont font = wb.createFont();<br />
font.setFontHeightInPoints((short)24);<br />
font.setFontName("Courier New");<br />
font.setItalic(true);<br />
font.setStrikeout(true);</p>
<p>// Fonts are set into a style so create a new one to use.<br />
HSSFCellStyle style = wb.createCellStyle();<br />
style.setFont(font);</p>
<p>// Create a cell and put a value in it.<br />
HSSFCell cell = row.createCell((short) 1);<br />
cell.setCellValue("This is a test of fonts");<br />
cell.setCellStyle(style);</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Tùy chỉnh màu sắc</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet();<br />
HSSFRow row = sheet.createRow((short) 0);<br />
HSSFCell cell = row.createCell((short) 0);<br />
cell.setCellValue("Default Palette");</p>
<p>//apply some colors from the standard palette,<br />
// as in the previous examples.<br />
//we'll use red text on a lime background</p>
<p>HSSFCellStyle style = wb.createCellStyle();<br />
style.setFillForegroundColor(HSSFColor.LIME.index);<br />
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);</p>
<p>HSSFFont font = wb.createFont();<br />
font.setColor(HSSFColor.RED.index);<br />
style.setFont(font);</p>
<p>cell.setCellStyle(style);</p>
<p>//save with the default palette<br />
FileOutputStream out = new FileOutputStream("default_palette.xls");<br />
wb.write(out);<br />
out.close();</p>
<p>//now, let's replace RED and LIME in the palette<br />
// with a more attractive combination<br />
// (lovingly borrowed from freebsd.org)</p>
<p>cell.setCellValue("Modified Palette");</p>
<p>//creating a custom palette for the workbook<br />
HSSFPalette palette = wb.getCustomPalette();</p>
<p>//replacing the standard red with freebsd.org red<br />
palette.setColorAtIndex(HSSFColor.RED.index,<br />
(byte) 153,  //RGB red (0-255)<br />
(byte) 0,    //RGB green<br />
(byte) 0     //RGB blue<br />
);<br />
//replacing lime with freebsd.org gold<br />
palette.setColorAtIndex(HSSFColor.LIME.index, (byte) 255, (byte) 204, (byte) 102);</p>
<p>//save with the modified palette<br />
// note that wherever we have previously used RED or LIME, the<br />
// new colors magically appear<br />
out = new FileOutputStream("modified_palette.xls");<br />
wb.write(out);<br />
out.close();<br />
</code><br />
<strong>Đọc và ghi</strong></p>
<p><code>POIFSFileSystem fs      =<br />
new POIFSFileSystem(new FileInputStream("workbook.xls"));<br />
HSSFWorkbook wb = new HSSFWorkbook(fs);<br />
HSSFSheet sheet = wb.getSheetAt(0);<br />
HSSFRow row = sheet.getRow(2);<br />
HSSFCell cell = row.getCell((short)3);<br />
if (cell == null)<br />
cell = row.createCell((short)3);<br />
cell.setCellType(HSSFCell.CELL_TYPE_STRING);<br />
cell.setCellValue("a test");</p>
<p>// Write the output to a file<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Làm việc với nhiều dòng trong cell.</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet s = wb.createSheet();<br />
HSSFRow r = null;<br />
HSSFCell c = null;<br />
HSSFCellStyle cs = wb.createCellStyle();<br />
HSSFFont f = wb.createFont();<br />
HSSFFont f2 = wb.createFont();</p>
<p>cs = wb.createCellStyle();</p>
<p>cs.setFont( f2 );<br />
//Word Wrap MUST be turned on<br />
cs.setWrapText( true );</p>
<p>r = s.createRow( (short) 2 );<br />
r.setHeight( (short) 0x349 );<br />
c = r.createCell( (short) 2 );<br />
c.setCellType( HSSFCell.CELL_TYPE_STRING );<br />
c.setCellValue( "Use \n with word wrap on to create a new line" );<br />
c.setCellStyle( cs );<br />
s.setColumnWidth( (short) 2, (short) ( ( 50 * 8 ) / ( (double) 1 / 20 ) ) );</p>
<p>FileOutputStream fileOut = new FileOutputStream( "workbook.xls" );<br />
wb.write( fileOut );<br />
fileOut.close();</code></p>
<p><strong>Định dạng dữ liệu<br />
</strong><br />
<code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("format sheet");<br />
HSSFCellStyle style;<br />
HSSFDataFormat format = wb.createDataFormat();<br />
HSSFRow row;<br />
HSSFCell cell;<br />
short rowNum = 0;<br />
short colNum = 0;</p>
<p>row = sheet.createRow(rowNum++);<br />
cell = row.createCell(colNum);<br />
cell.setCellValue(11111.25);<br />
style = wb.createCellStyle();<br />
style.setDataFormat(format.getFormat("0.0"));<br />
cell.setCellStyle(style);</p>
<p>row = sheet.createRow(rowNum++);<br />
cell = row.createCell(colNum);<br />
cell.setCellValue(11111.25);<br />
style = wb.createCellStyle();<br />
style.setDataFormat(format.getFormat("#,##0.0000"));<br />
cell.setCellStyle(style);</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Chỉnh kích thước Sheet</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("format sheet");<br />
HSSFPrintSetup ps = sheet.getPrintSetup();</p>
<p>sheet.setAutobreaks(true);</p>
<p>ps.setFitHeight((short)1);<br />
ps.setFitWidth((short)1);</p>
<p>// Create various cells and rows for spreadsheet.</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();<br />
</code><br />
<strong>Print</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("Sheet1");<br />
wb.setPrintArea(0, "$A$1:$C$2");<br />
//sets the print area for the first sheet<br />
//Alternatively:<br />
//wb.setPrintArea(0, 0, 1, 0, 0) is equivalent to using the name reference (See the JavaDocs for more details)</p>
<p>// Create various cells and rows for spreadsheet.</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Đánh số trang cho footer trong sheet</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("format sheet");<br />
HSSFFooter footer = sheet.getFooter();</p>
<p>footer.setRight( "Page " + HSSFFooter.page() + " of " + HSSFFooter.numPages() );</p>
<p>// Create various cells and rows for spreadsheet.</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Convenience Functions</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet1 = wb.createSheet( "new sheet" );</p>
<p>// Create a merged region<br />
HSSFRow row = sheet1.createRow( (short) 1 );<br />
HSSFRow row2 = sheet1.createRow( (short) 2 );<br />
HSSFCell cell = row.createCell( (short) 1 );<br />
cell.setCellValue( "This is a test of merging" );<br />
Region region = new Region( 1, (short) 1, 4, (short) 4 );<br />
sheet1.addMergedRegion( region );</p>
<p>// Set the border and border colors.<br />
final short borderMediumDashed = HSSFCellStyle.BORDER_MEDIUM_DASHED;<br />
HSSFRegionUtil.setBorderBottom( borderMediumDashed,<br />
region, sheet1, wb );<br />
HSSFRegionUtil.setBorderTop( borderMediumDashed,<br />
region, sheet1, wb );<br />
HSSFRegionUtil.setBorderLeft( borderMediumDashed,<br />
region, sheet1, wb );<br />
HSSFRegionUtil.setBorderRight( borderMediumDashed,<br />
region, sheet1, wb );<br />
HSSFRegionUtil.setBottomBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);<br />
HSSFRegionUtil.setTopBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);<br />
HSSFRegionUtil.setLeftBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);<br />
HSSFRegionUtil.setRightBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);</p>
<p>// Shows some usages of HSSFCellUtil<br />
HSSFCellStyle style = wb.createCellStyle();<br />
style.setIndention((short)4);<br />
HSSFCellUtil.createCell(row, 8, "This is the value of the cell", style);<br />
HSSFCell cell2 = HSSFCellUtil.createCell( row2, 8, "This is the value of the cell");<br />
HSSFCellUtil.setAlignment(cell2, wb, HSSFCellStyle.ALIGN_CENTER);</p>
<p>// Write out the workbook<br />
FileOutputStream fileOut = new FileOutputStream( "workbook.xls" );<br />
wb.write( fileOut );<br />
fileOut.close();</code></p>
<p><strong>Hoán đổi dòng</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("row sheet");</p>
<p>// Create various cells and rows for spreadsheet.</p>
<p>// Shift rows 6 - 11 on the spreadsheet to the top (rows 0 - 5)<br />
sheet.shiftRows(5, 10, -5);</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Chọn sheet</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("row sheet");<br />
sheet.setSelected(true);</p>
<p>// Create various cells and rows for spreadsheet.</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Chọn hiển thị cho sheet</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet1 = wb.createSheet("new sheet");<br />
sheet1.setZoom(3,4);   // 75 percent magnification<br />
FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Chia dòng, cell</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet1 = wb.createSheet("new sheet");<br />
HSSFSheet sheet2 = wb.createSheet("second sheet");<br />
HSSFSheet sheet3 = wb.createSheet("third sheet");<br />
HSSFSheet sheet4 = wb.createSheet("fourth sheet");</p>
<p>// Freeze just one row<br />
sheet1.createFreezePane( 0, 1, 0, 1 );<br />
// Freeze just one column<br />
sheet2.createFreezePane( 1, 0, 1, 0 );<br />
// Freeze the columns and rows (forget about scrolling position of the lower right quadrant).<br />
sheet3.createFreezePane( 2, 2 );<br />
// Create a split with the lower left side being the active quadrant<br />
sheet4.createSplitPane( 2000, 2000, 0, 0, HSSFSheet.PANE_LOWER_LEFT );</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Repeating rows and columns</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet1 = wb.createSheet("new sheet");<br />
HSSFSheet sheet2 = wb.createSheet("second sheet");</p>
<p>// Set the columns to repeat from column 0 to 2 on the first sheet<br />
wb.setRepeatingRowsAndColumns(0,0,2,-1,-1);</p>
<p>// Set the the repeating rows and columns on the second sheet.<br />
wb.setRepeatingRowsAndColumns(1,4,5,1,2);</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Headers and Footers</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("new sheet");</p>
<p>HSSFHeader header = sheet.getHeader();<br />
header.setCenter("Center Header");<br />
header.setLeft("Left Header");<br />
header.setRight(HSSFHeader.font("Stencil-Normal", "Italic") +<br />
HSSFHeader.fontSize((short) 16) + "Right w/ Stencil-Normal Italic font and size 16");</p>
<p>FileOutputStream fileOut = new FileOutputStream("workbook.xls");<br />
wb.write(fileOut);<br />
fileOut.close();</code><br />
<strong><br />
Drawing Shapes</strong></p>
<p><code>HSSFFont font = wb.createFont();<br />
font.setItalic(true);<br />
font.setUnderline(HSSFFont.U_DOUBLE);<br />
HSSFRichTextString string = new HSSFRichTextString("Woo!!!");<br />
string.applyFont(2,5,font);<br />
textbox.setString(string );</p>
<p>// Create a shape group.<br />
HSSFShapeGroup group = patriarch.createGroup(<br />
new HSSFClientAnchor(0,0,900,200,(short)2,2,(short)2,2));</p>
<p>// Create a couple of lines in the group.<br />
HSSFSimpleShape shape1 = group.createShape(new HSSFChildAnchor(3,3,500,500));<br />
shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);<br />
( (HSSFChildAnchor) shape1.getAnchor() ).setAnchor((short)3,3,500,500);<br />
HSSFSimpleShape shape2 = group.createShape(new HSSFChildAnchor((short)1,200,400,600));<br />
shape2.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);</p>
<p>myGroup.setCoordinates(10,10,20,20); // top-left, bottom-right</code><br />
<strong><br />
Styling Shapes</strong></p>
<p><code>HSSFSimpleShape s = patriarch.createSimpleShape(a);<br />
s.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL);<br />
s.setLineStyleColor(10,10,10);<br />
s.setFillColor(90,10,200);<br />
s.setLineWidth(HSSFShape.LINEWIDTH_ONE_PT * 3);<br />
s.setLineStyle(HSSFShape.LINESTYLE_DOTSYS);</code><br />
<strong><br />
Shapes and Graphics2d</strong></p>
<p><code>a = new HSSFClientAnchor( 0, 0, 1023, 255, (short) 1, 0, (short) 1, 0 );<br />
group = patriarch.createGroup( a );<br />
group.setCoordinates( 0, 0, 80 * 4 , 12 * 23  );<br />
float verticalPointsPerPixel = a.getAnchorHeightInPoints(sheet) / (float)Math.abs(group.getY2() - group.getY1());<br />
g = new EscherGraphics( group, wb, Color.black, verticalPointsPerPixel );<br />
g2d = new EscherGraphics2d( g );<br />
drawChemicalStructure( g2d );</code><br />
<strong><br />
Outlining</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet1 = wb.createSheet("new sheet");</p>
<p>sheet1.groupRow( 5, 14 );<br />
sheet1.groupRow( 7, 14 );<br />
sheet1.groupRow( 16, 19 );</p>
<p>sheet1.groupColumn( (short)4, (short)7 );<br />
sheet1.groupColumn( (short)9, (short)12 );<br />
sheet1.groupColumn( (short)10, (short)11 );</p>
<p>FileOutputStream fileOut = new FileOutputStream(filename);<br />
wb.write(fileOut);<br />
fileOut.close();</code></p>
<p><strong>Hình ảnh</strong></p>
<p><code>// Create the drawing patriarch.  This is the top level container for<br />
// all shapes. This will clear out any existing shapes for that sheet.<br />
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();</p>
<p>HSSFClientAnchor anchor;<br />
anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);<br />
anchor.setAnchorType( 2 );<br />
patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));</p>
<p>HSSFWorkbook wb;</p>
<p>List lst = wb.getAllPictures();<br />
for (Iterator it = lst.iterator(); it.hasNext(); ) {<br />
HSSFPictureData pict = (HSSFPictureData)it.next();<br />
String ext = pict.suggestFileExtension();<br />
byte[] data = pict.getData();<br />
if (ext.equals("jpeg")){<br />
FileOutputStream out = new FileOutputStream("pict.jpg");<br />
out.write(data);<br />
out.close();<br />
}<br />
}</code></p>
<p><strong>Định danh một cụm và định danh một Cell</strong></p>
<p><code>// setup code<br />
String sname = "TestSheet", cname = "TestName", cvalue = "TestVal";<br />
HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet(sname);<br />
sheet.createRow(0).createCell((short) 0).setCellValue(cvalue);</p>
<p>// 1. create named range for a single cell using areareference<br />
HSSFName namedCell = wb.createName();<br />
namedCell.setNameName(cname);<br />
String reference = sname+"!A1:A1"; // area reference<br />
namedCell.setReference(reference);</p>
<p>// 2. create named range for a single cell using cellreference<br />
HSSFName namedCell = wb.createName();<br />
namedCell.setNameName(cname);<br />
String reference = sname+"!A1"; // cell reference<br />
namedCell.setReference(reference);</p>
<p>// 3. create named range for an area using AreaReference<br />
HSSFName namedCell = wb.createName();<br />
namedCell.setNameName(cname);<br />
String reference = sname+"!A1:C5"; // area reference<br />
namedCell.setReference(reference);</p>
<p>// setup code<br />
String cname = "TestName";<br />
HSSFWorkbook wb = getMyWorkbook(); // retrieve workbook</p>
<p>// retrieve the named range<br />
int namedCellIdx = wb.getNameIndex(cellName);<br />
HSSFName aNamedCell = wb.getNameAt(namedCellIdx);</p>
<p>// retrieve the cell at the named range and test its contents<br />
AreaReference aref = new AreaReference(aNamedCell.getReference());</p>
<p>CellReference[] crefs = aref.getCells();<br />
for (int i=0; i<br />
HSSFSheet s = wb.getSheet(crefs[i].getSheetName());<br />
HSSFRow r = sheet.getRow(crefs[i].getRow());<br />
HSSFCell c = r.getCell(crefs[i].getCol());<br />
// extract the cell contents based on cell type etc.<br />
}<br />
</code><br />
<strong>Thiết lập comment cho cell</strong></p>
<p><code>HSSFWorkbook wb = new HSSFWorkbook();<br />
HSSFSheet sheet = wb.createSheet("Cell comments in POI HSSF");</p>
<p>// Create the drawing patriarch. This is the top level container for all shapes including cell comments.<br />
HSSFPatriarch patr = sheet.createDrawingPatriarch();</p>
<p>//create a cell in row 3<br />
HSSFCell cell1 = sheet.createRow(3).createCell((short)1);<br />
cell1.setCellValue(new HSSFRichTextString("Hello, World"));</p>
<p>//anchor defines size and position of the comment in worksheet<br />
HSSFComment comment1 = patr.createComment(new HSSFClientAnchor(0, 0, 0, 0, (short)4, 2, (short) 6, 5));</p>
<p>// set text in the comment<br />
comment1.setString(new HSSFRichTextString("We can set comments in POI"));</p>
<p>//set comment author.<br />
//you can see it in the status bar when moving mouse over the commented cell<br />
comment1.setAuthor("Apache Software Foundation");</p>
<p>// The first way to assign comment to a cell is via HSSFCell.setCellComment method<br />
cell1.setCellComment(comment1);</p>
<p>//create another cell in row 6<br />
HSSFCell cell2 = sheet.createRow(6).createCell((short)1);<br />
cell2.setCellValue(36.6);</p>
<p>HSSFComment comment2 = patr.createComment(new HSSFClientAnchor(0, 0, 0, 0, (short)4, 8, (short) 6, 11));<br />
//modify background color of the comment<br />
comment2.setFillColor(204, 236, 255);</p>
<p>HSSFRichTextString string = new HSSFRichTextString("Normal body temperature");</p>
<p>//apply custom font to the text in the comment<br />
HSSFFont font = wb.createFont();<br />
font.setFontName("Arial");<br />
font.setFontHeightInPoints((short)10);<br />
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);<br />
font.setColor(HSSFColor.RED.index);<br />
string.applyFont(font);</p>
<p>comment2.setString(string);<br />
//by default comments are hidden. This one is always visible.<br />
comment2.setVisible(true);</p>
<p>comment2.setAuthor("Bill Gates");</p>
<p>/**<br />
* The second way to assign comment to a cell is to implicitly specify its row and column.<br />
* Note, it is possible to set row and column of a non-existing cell.<br />
* It works, the commnet is visible.<br />
*/<br />
comment2.setRow(6);<br />
comment2.setColumn((short)1);</p>
<p>FileOutputStream out = new FileOutputStream("poi_comment.xls");<br />
wb.write(out);<br />
out.close();</p>
<p>HSSFCell cell = sheet.get(3).getColumn((short)1);     HSSFComment comment = cell.getCellComment();     if (comment != null) {       HSSFRichTextString str = comment.getString();       String author = comment.getAuthor();     }     //  alternatively you can retrieve cell comments by (row, column)     comment = sheet.getCellComment(3, 1);</code></p>
<p><strong>Chỉnh kích thước column vừa với nội dung</strong></p>
<p><code>HSSFSheet sheet = workbook.getSheetAt(0);<br />
sheet.autoSizeColumn((short)0); //adjust width of the first column<br />
sheet.autoSizeColumn((short)1); //adjust width of the second column</code><br />
</font></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Step by Step Instructions on How to Run a Jasper Report from Java]]></title>
<link>http://oldlight.wordpress.com/?p=17</link>
<pubDate>Fri, 11 Apr 2008 03:31:48 +0000</pubDate>
<dc:creator>oldlight</dc:creator>
<guid>http://oldlight.wordpress.com/?p=17</guid>
<description><![CDATA[Nguồn: http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html
Oguzhan Topsakal
M]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><strong>Nguồn</strong>: <a href="http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html" target="_blank">http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html</a></p>
<p align="center"><strong>Oguzhan Topsakal</strong></p>
<p align="center"><strong>March 2006</strong></p>
<p><span style="font-size:medium;">This mini-tutorial shows you how to run a report (Jasper  Report) from Java code. To run a Jasper Report from Java code you need the  following Jasper Report libraries (jar files): </span></p>
<ul>
<li><span style="font-size:medium;">jasperreports-1.2.0.jar, </span></li>
<li><span style="font-size:medium;">commons-beanutils-1.5.jar, </span></li>
<li><span style="font-size:medium;">commons-collections-2.1.jar, </span></li>
<li><span style="font-size:medium;">commons-digester-1.7.jar, </span></li>
<li><span style="font-size:medium;">commons-logging-1.0.2.jar. </span></li>
</ul>
<p><span style="font-size:medium;">You can find these libraries inside the <em>lib</em> directory  of the iReport-1.2.0 installation. (For instance, if you have installed iReport  in the <a href="/Courses/CIS4301/ReportGenerator/iReport-1.2"> C:\Courses\CIS4301\ReportGenerator\iReport-1.2.0</a> directory, you can find  these libraries in <a href="/Courses/CIS4301/ReportGenerator/iReport-1.2"> C:\Courses\CIS4301\ReportGenerator\iReport-1.2.0\lib</a> directory. For  information on how to install iReport check this <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/PrepareAReport.html"> page</a>.)</span></p>
<p><span style="font-size:medium;">You also need the oracle JDBC library (classes12.jar file) to  connect to the database. You need to put these files into your Java CLASSPATH. </span></p>
<p><span style="font-size:medium;">The following Java code uses a Jasper Report design (<em>reportFile </em>paramater) and fills the report with data from database and views the  report. An example of a Jasper Report is given <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/jrTemplate/YourUFID_1.jrxml">here</a>.</span></p>
<table id="AutoNumber1" border="1" cellspacing="1" width="100%">
<tbody>
<tr>
<td width="100%"><span style="font-family:Arial;">public static void runReport(String      databaseName, String userName, String password,String reportFile) {<br />
try{<br />
JasperDesign      jasperDesign = JRXmlLoader.load(reportFile);<br />
JasperReport      jasperReport = JasperCompileManager.compileReport(jasperDesign);<br />
Connection      jdbcConnection = connectDB(databaseName, userName, password);<br />
JasperPrint      jasperPrint = JasperFillManager.fillReport(jasperReport, null,      jdbcConnection);<br />
JasperViewer.viewReport(jasperPrint);<br />
}catch(Exception ex) {<br />
String connectMsg =      "Could not create the report " + ex.getMessage() + " " +      ex.getLocalizedMessage();<br />
System.out.println(connectMsg);<br />
}<br />
}</span></td>
</tr>
</tbody>
</table>
<p><span style="font-size:medium;">The complete Java Class code is as the following: <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/jrJava/ReportDriver.java">ReportDriver.java</a> </span></p>
<p><span style="font-size:medium;">You can use <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/jrJava/ReportDriver.java"> ReportDriver.java</a> as a driver program from other Java classes as well. Here  is an <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/jrJava/DriveReportDriver.java">example</a>.</span></p>
<table id="AutoNumber2" border="1" cellspacing="1" width="100%">
<tbody>
<tr>
<td width="100%"><span style="font-family:Arial;">import java.sql.*;<br />
import net.sf.jasperreports.view.JasperViewer;<br />
import net.sf.jasperreports.engine.xml.JRXmlLoader;<br />
import net.sf.jasperreports.engine.JasperCompileManager;<br />
import net.sf.jasperreports.engine.JasperFillManager;<br />
import net.sf.jasperreports.engine.JasperPrint;<br />
import net.sf.jasperreports.engine.design.JasperDesign;<br />
import net.sf.jasperreports.engine.JasperReport;<br />
import java.io.OutputStream;</p>
<p>/**<br />
* Driver program to connect to a database and to view a jasper report (.jrxml)<br />
* @author Oguzhan Topsakal<br />
* @since 23 March 2006<br />
*<br />
* Required jar files to run this class:<br />
* 1. jasperreports-1.2.0.jar<br />
* 2. classes12.jar (for Oracle JDBC connection)<br />
* 3. commons-beanutils-1.5.jar<br />
* 4. commons-collections-2.1.jar<br />
* 5. commons-digester-1.7.jar<br />
* 6. commons-logging-1.0.2.jar<br />
*<br />
*/</p>
<p>public class ReportDriver {</p>
<p>/**<br />
* Constructor for ReportDriver<br />
*/<br />
public ReportDriver() {<br />
}</p>
<p>/**<br />
* Takes 3 parameters: databaseName, userName, password<br />
* and connects to the database.<br />
* @param databaseName holds database name,<br />
* @param userName holds user name<br />
* @param password holds password to connect the database,<br />
* @return Returns the JDBC connection to the database<br />
*/<br />
public static Connection connectDB(String databaseName, String      userName, String password) {<br />
Connection jdbcConnection = null;<br />
try{<br />
Class.forName("oracle.jdbc.driver.OracleDriver");<br />
jdbcConnection =      DriverManager.getConnection(databaseName,userName,password);<br />
}catch(Exception ex) {<br />
String connectMsg = "Could not      connect to the database: " + ex.getMessage() + " " + ex.getLocalizedMessage();<br />
System.out.println(connectMsg);<br />
}<br />
return jdbcConnection;<br />
}</p>
<p>/**<br />
* Takes 4 parameters: databaseName, userName, password,      reportFileLocation<br />
* and connects to the database and prepares and views the report.<br />
* @param databaseName holds database name,<br />
* @param userName holds user name<br />
* @param password holds password to connect the database,<br />
* @param reportFile holds the location of the Jasper Report file (.jrxml)<br />
*/<br />
public static void runReport(String databaseName, String userName,      String password,String reportFile) {<br />
try{<br />
JasperDesign jasperDesign =      JRXmlLoader.load(reportFile);<br />
JasperReport jasperReport =      JasperCompileManager.compileReport(jasperDesign);<br />
Connection jdbcConnection =      connectDB(databaseName, userName, password);<br />
JasperPrint jasperPrint =      JasperFillManager.fillReport(jasperReport, null, jdbcConnection);<br />
JasperViewer.viewReport(jasperPrint);<br />
}catch(Exception ex) {<br />
String connectMsg = "Could not      create the report " + ex.getMessage() + " " + ex.getLocalizedMessage();<br />
System.out.println(connectMsg);<br />
}<br />
}</p>
<p>/**<br />
* Uses runReport method to connect to the database and to prepare      and view the report.<br />
* @param args Takes 4 arguments as an input: databaseName, userName,      password, reportFileLocation<br />
* args[0] holds database name,<br />
* args[1] holds user name<br />
* args[2] holds password to connect the database,<br />
* args[3] holds the location of the Jasper Report file (.jrxml)<br />
*/<br />
public static void main(String[] args) {<br />
if (args.length == 4) {<br />
String databaseName = args[0] ;<br />
String userName = args[1];<br />
String password = args[2];<br />
String reportFile = args[3];<br />
runReport(databaseName,      userName, password, reportFile);<br />
}else{<br />
System.out.println("Usage:");<br />
System.out.println("java      ReportDriver databaseName userName password reportFileLocation");<br />
}<br />
return;<br />
}<br />
}</p>
<p></span></td>
</tr>
</tbody>
</table>
<p><span style="font-size:medium;">A <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/jrJava/compileReportDriver.bat">batch file that  compiles </a>the above Java Class is like the following (Please note that all  the library classes are placed inside the <em>javaLib </em>directory under the  current working directory) :</span></p>
<table id="AutoNumber3" border="1" cellspacing="1" width="100%">
<tbody>
<tr>
<td width="100%">javac -classpath .;javaLib\classes12.jar;javaLib\jasperreports-1.2.0.jar      ReportDriver.java<br />
pause</td>
</tr>
</tbody>
</table>
<p><span style="font-size:medium;">A <a href="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/jrJava/runReportDriver.bat">batch file that runs</a> the ReportDriver Java class is like the following (Again, please note that all  the library classes are placed inside the <em>javaLib </em>directory under the  current working directory):</span></p>
<table id="AutoNumber4" border="1" cellspacing="1" width="100%">
<tbody>
<tr>
<td width="100%">REM first parameter is your Oracle connection string. For      instance, jdbc:oracle:thin:@oracle1.cise.ufl.edu:1521:orcl<br />
REM second parameter is your Oracle database user name<br />
REM third parameter is database password<br />
REM fourth parameter is report file location. For instance,      C:\Courses\CIS4301\WEBPAGE\ReportDemo\jrTemplate\YourUFID_1.jrxml<br />
java -cp .;javaLib\classes12.jar;javaLib\jasperreports-1.2.0.jar;javaLib\commons-digester-1.7.jar;javaLib\commons-collections-2.1.jar;javaLib\commons-logging-1.0.2.jar;javaLib\commons-beanutils-1.5.jar ReportDriver %1 %2 %3 %4<br />
pause</td>
</tr>
</tbody>
</table>
<p><span style="font-size:medium;">Here is an image showing how I run the above batch file:</span></p>
<p><img src="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/runBatch.jpg" border="0" alt="" width="669" height="338" /></p>
<p><span style="font-size:medium;">This is the report I get after running my Jasper Report  template:</span></p>
<p><img src="http://www.cise.ufl.edu/%7Eotopsaka/CIS4301/ReportDemo/iReport4.jpg" border="0" alt="" width="836" height="491" /></p>
<p><span style="font-size:medium;">For Jasper Report API: </span> <a href="http://jasperreports.sourceforge.net/api/index.html"><span style="font-size:medium;"> http://jasperreports.sourceforge.net/api/index.html</span></a></p>
<p><span style="font-size:medium;">For commons library API: <a href="http://jakarta.apache.org/commons/">http://jakarta.apache.org/commons/</a> </span></p>
<p><strong>Prepared by <em><a href="http://www.topsakal.net/">Oguzhan Topsakal</a></em></strong></p>
<p><strong>March, 2006</strong></p>
<div>
 <a href="http://whos.amung.us/show/x52wzetd"><img src="http://whos.amung.us/widget/x52wzetd.png" alt="site statistics" width="81" height="29" border="0" /></a>
</div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The 7 CSS Hacks that we should use]]></title>
<link>http://oldlight.wordpress.com/?p=13</link>
<pubDate>Sun, 10 Feb 2008 12:57:50 +0000</pubDate>
<dc:creator>oldlight</dc:creator>
<guid>http://oldlight.wordpress.com/?p=13</guid>
<description><![CDATA[Source: http://www.noupe.com
If you are trying to do pixel-perfect cross-browser CSS layout, then yo]]></description>
<content:encoded><![CDATA[<p>Source: <a href="http://www.noupe.com/better-design/7-css-hacks-you-cannt-live-without.html" target="_blank">http://www.noupe.com</a></p>
<p><font size="2">If you are trying to do pixel-perfect cross-browser <b>CSS</b> layout, then you have probably ran into problems with IE . I am going to highlight the top 7 CSS hacks that we often use to have pixel perfect design.</font></p>
<h5>1)<a href="http://tantek.com/CSS/Examples/boxmodelhack.html">Box Model Hack</a></h5>
<p>The box model hack is used to fix a rendering problem in pre-IE 6 browsers, where the border and padding are included in the width of an element, as opposed to added on</p>
<pre><code> padding: 4em; border: 1em solid red; width: 30em; width/**/:/**/ 25em;</code></pre>
<p><!-- google_ad_client = "pub-5772113346494698"; //wide skinny ad white google_ad_slot = "1678617330"; google_ad_width = 468; google_ad_height = 15; //--></p>
<h5>2) Conditional Comments</h5>
<p>These conditional comments are for IE-only and they’re not supported by any other browser. For other browsers they are just an ordinary comments and therefor, they are safe to use.</p>
<p>The typical usage is as follows:</p>
<pre><code>&#60;!--[if IE]&#62;    Some CssCode&#60;![endif]--&#62;</code></pre>
<p>The above code applies to all versions of Internet Explorer, i.e. 5.01, 5.5 and 6.0, but now we want to apply it to versions of Internet Explorer, i.e. 5.01, 5.5 and 6.0, so we will apply the following condition:</p>
<pre><code>&#60;!--[if lte IE 6]&#62;    Some Css Code&#60;![endif]--&#62;</code></pre>
<p>After we finish testing, we remove all hacks to separate file(s), so the main CSS is clean and tidy. This separate file is then called in the header section of a file within conditional comments.</p>
<pre><code>&#60;!--[if lte IE 6]&#62;    &#60;link rel="stylesheet" type="text/css" href="ie_hacks.css" /&#62;&#60;![endif]--&#62;<!--/code--></code></pre>
<p><b>Condition is one of the following:</b></p>
<ul>
<li>IE (Any version of IE)</li>
<li>lt IE version (Versions less than version)</li>
<li>lte IE version(Versions less than or equal to version)</li>
<li>IE version (Only version)</li>
<li>gte IE version (Versions greater than or equal to version)</li>
<li>gt IE version (Versions greater than version)</li>
</ul>
<p>Version is the version of Internet Explorer, typically 5, 5.5, 6, or 7, you can read more info about this  <a href="http://www.quirksmode.org/css/condcom.html">at Quirksmode.</a></p>
<h5>3) Min-width and Max-width of an element</h5>
<p>IE doesn’t understand this command, so we’ll need a new way of making this work in this browser. Let’s take a quick example, we need to apply this to a div with id="wrapper":</p>
<pre><code>&#60;wrapper&#62;&#60;div id="nav"&#62;</code></pre>
<p>Next we create our CSS commands, so as to create a minimum width of 750px:</p>
<pre><code> #wrapper{min-width: 750px;width:expression(document.body.clientWidth &#60; 750? "750px": "auto" );} </code></pre>
<p>You might also want to combine this minimum width of 750px with a maximum width 1220px:</p>
<pre><code>#wrapper{min-width: 750px;max-width: 1220px;width:expression(document.body.clientWidth &#60; 750? "750px" : document.body.clientWidth &#62; 1220? "1220px" : "auto");}</code></pre>
<p>Another Alternative for for min-height without javascript is to use <a href="http://www.dustindiaz.com/min-height-fast-hack/Min-Height">Dustin Diaz’</a> nice hack:  :</p>
<pre><code>#id{ min-height: 100px; height:auto !important; height:100px; } </code></pre>
<h5>4) Easy Selectors</h5>
<p>Most in-CSS hacks deal with selector bugs. Below is a list of different IE versions and the beginnings of selectors that are known to select elements in them. All of these selectors use valid CSS.</p>
<ul>
<li>IE 6 and below
<pre><code>* html {}</code></pre>
</li>
<li>IE 7 and below
<pre><code>*:first-child+html {} * html {}</code></pre>
</li>
<li>IE 7 only
<pre><code>*:first-child+html {}</code></pre>
</li>
<li>IE 7 and modern browsers only
<pre><code> html&#62;body {}</code></pre>
</li>
<li>Modern browsers only (not IE 7)
<pre><code> html&#62;/**/body {}</code></pre>
</li>
<li>Recent Opera versions 9 and below
<pre><code>html:first-child {} </code></pre>
</li>
</ul>
<h5>5)Whatever: hover</h5>
<p>The :hover selector enables you to have cool effect for html elements like and in tables.Most browsers have no problem with this, except IE which look at the stylesheets and each individual rule with javascript.<br />
If :hover rules can be tracked, and .htc can be used to change an elements behavior, then it should be possible to create a behavior that enables :hover for any element.</p>
<p>You can read more about this <a href="http://www.xs4all.nl/%7Epeterned/csshover.html">here</a></p>
<h5>6)Transparent PNGs</h5>
<p>IE dosn’t handle transparent PNG too well. You’ll get an ugly grayish type background wherever it’s supposed to be transparent. And we cann’t just use GIFs because aren’t good for higher resolution images. So we need a CSS hack to fix this. Follow the following steps and you will be set:</p>
<ul>
<li>A HTC script and a transparent GIF will be used to solve this issue. You can download both files <a href="http://noupe.com/img/transparentpngs.zip">here</a></li>
<li>Now just upload these 2 files to wherever you store your IE.css file.</li>
<li>Add one simple line of CSS code to your ie.css file:
<pre><code> img.pngfix { 	behavior: url(pngHack.htc); }</code></pre>
</li>
</ul>
<p>Another solution can be found at <a href="http://komodomedia.com/blog/index.php/2007/11/05/css-png-image-fix-for-ie/">Komodomedia</a></p>
<h5>7) <a href="http://www.stylegala.com/articles/no_more_css_hacks.htm">Stylegala- No More CSS Hacks</a></h5>
<p>Stylegala’s method is to detect browser version and serve different CSS rules to different user agents, without using hacks or conditional comments. At the same time the end user or validator will never see the CSS rules specified for other browsers than the one they are using. He used some simple PHP code to detect browser type exactly as any CSS hack.</p>
<h5>Further Readings</h5>
<ul>
<li><a href="http://centricle.com/ref/css/filters/">Will the browser apply the rule(s)?</a></li>
<li><a href="http://24ways.org/2005/avoiding-css-hacks-for-internet-explorer">Avoiding CSS Hacks for Internet Explorer</a></li>
</ul>
<div>
<h6>Credits</h6>
<p>Thanks to our friends <b>"<a href="http://xhtml-css.com/">Karim</a>" and "pacotole"</b> for pointing out Dustin Diaz’ nice hack for min-height.</p>
<p>Thanks to our friend <b>"<a href="http://www.narga.net/">Narga</a>"</b> for creating a vietnamese translation page on http://www.narga.net/348</div>
<div align="center">
 <a href="http://whos.amung.us/show/x52wzetd"><img src="http://whos.amung.us/widget/x52wzetd.png" alt="site statistics" width="81" height="25" border="0" /></a>
</div>
]]></content:encoded>
</item>

</channel>
</rss>
