Hi 👋
My blogs home has been moved to my personal website:
🔗 https://www.lasantha.org/blog/
Please visit that page from now onward to see latest blog posts.
Thank you! 🙏
Hi 👋
My blogs home has been moved to my personal website:
🔗 https://www.lasantha.org/blog/
Please visit that page from now onward to see latest blog posts.
Thank you! 🙏
Hello World, it works.
For All Hackintosh enthusiasts,
I got my Diamond ATI Radeon HD 4870 512mb working successfully with QE/CI support. Used OSx 10.5.7 & Natit pkg.
I tried nVidia GTS 250 and GTX 260 but did not have any luck, so I had to gamble with a new 4870 and it paid off.
I had a requirement for the project I am working on, to generate a data table with dynamic column ordering. I use JSF 1.2 and Facelets. There were several option I could have used meeting the following criteria.
So I did a lot of research and this is the solution I came up with.
<table>
<thead>
<tr>
<ui:repeat value="#{mycontroller.columnIdList}" var="columnid">
<ui:fragment rendered="${columnid == 1}">
<th>My Column 1 Header</th>
</ui:fragment>
<ui:fragment rendered="${columnid == 2}">
<th>My Column 2 Header</th>
</ui:fragment>
<ui:fragment rendered="${columnid == 3}">
<th>My Column 3 Header</th>
</ui:fragment>
</ui:repeat>
</tr>
</thead>
<tbody>
<ui:repeat value="#{mycontroller.dataList}" var="data">
<tr>
<ui:repeat value="#{mycontroller.columnIdList}" var="columnid">
<ui:fragment rendered="${columnid == 1}">
<td><h:outputText value="#{data.field1Value}" /></td>
</ui:fragment>
<ui:fragment rendered="${columnid == 2}">
<td><h:outputText value="#{data.field2Value}" /></td>
</ui:fragment>
<ui:fragment rendered="${columnid == 3}">
<td><h:outputText value="#{data.field3Value}" /></td>
</ui:fragment>
</ui:repeat>
</tr>
</ui:repeat>
</tbody>
</table>
As you can see here; I have numbered each column with a unique id, my controller has a list of column ids in the required order.
List<Integer> columnIds = new ArrayList<Integer>();
And I am reading the column ids in Facelets ui:repeat tag inside the table header row and putting it in the correct order. In the table body I have two ui:repeat tags; one to traverse through my data model objects list & another one to get the correct field according to the column order. The only problem I see here is, it has a complexity of O(n2). It can be trimmed down to O(n) by creating your own data table JSF component; which I did not want to do. And for a small number of columns, I think this this solution is fair enough.
If you are familiar with JSF ( and perhaps with Facelets too) the about piece of code is self-explanatory. Let me know if you have any questions. And also I would like to get your feed back.
There is a good news for the Ruby community. The major Ruby release 1.9 is out. It is said that the new version is twice as fast as 1.8.
Link: http://www.ruby-lang.org/en/news/2009/01/30/ruby-1-9-1-released/
<application>
<view-handler>
com.sun.facelets.FaceletViewHandler
</view-handler>
</application>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
Our JSF pages should have the file extension ‘.xhtml’ and you can have a servelet mapping '*.jsf' files for the faces servlet. In that way, the actual page 'mypage.xhtml' can be accessed as 'mypage.jsf'.
One of the main advantages of Facelets is its use as a templating tool for JSF pages. You simply creates a basic layout page, divide it into logical areas as you wish (with ui:insert tags) and implements the basic contents in those logical areas. Then, for any page in your application that you want to use the template just have to put ui:composition tag in the page and override any implementation of the logical areas with ui:define tag. This is a very simple and elegant way of doing page templating; something I was looking for quite a sometime. Let's see this example;
This is my template: layout.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<!--
Author : Lasantha Kularatne
Date : Jan 27, 2009
Version : 1.0
Copy Rights : Lasantha Kularatne
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<ui:insert name="scriptslinks">
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript" src="../js/myjsfile.js"></script>
</ui:insert>
<title><ui:insert name="title">My Portal</ui:insert></title>
</head>
<body>
<!-- header -->
<ui:insert name="myheader"><ui:include src="header.xhtml"/></ui:insert>
<!-- data -->
<ui:insert name="mydata"></ui:insert>
<!-- footer -->
<ui:insert name="myfooter"><ui:include src="footer.xhtml"/></ui:insert>
</body>
</html>
I have divided my page into three logical areas called myheader, mydata and myfooter. I have basic implementations for header and footer in header.xhtml and footer.xhtml respectively, but not for the data area. Also I have two more logical areas for title and links/scripts.
Let's see how we can use this template: mypage.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="./layout.xhtml">
<ui:define name="title"><h:outputText value="#{bundle.TESTPAGE_TITLE}" /></ui:define>
<ui:define name="mydata">
<h:form id="MyForm">
...
</h:form>
</ui:define>
</ui:composition>
</html>
As you can see here, I have overridden the title and data areas. I put the title reading from my resource bundle and I have used a JSF form element in m data area. <ui:composition> tag is used to compose the page and notice that template reference (layout.xhtml). You have to give the template file name with the relative path.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<ui:component>
<div id="mylogo">
<a href="http://www.mycompanypage.com">
<span>My Company Pvt Ltd.</span>
</a>
</div>
</ui:component>
</html>
Notice that, although here we have some tags around ui:component tag, those will be discarded by the Facelets engine. Those tags are there only to identify the page by editors.
For further information, read about these tags and get familiar how you can use them in your project.
APC: Do you use a specific distribution of Linux at home or work?
LT: A "specific" one? No. I have changed distributions over the years, and it tends to really end up depending on various random circumstances, like just when I switch machines around and what happens to be convenient.
So right now I happen to run Fedora on my machines, which largely came about from me running on POWER for a few years, and Fedora supported it pretty well (and since I actually don't care that deeply about the distribution, I tend to prefer running the same thing on everything, just to keep any distro issues away).
Before Fedora had PowerPC support, I ran YDL for a while, and before that I had SuSE. Funnily enough, the only distributions I tend to refuse to touch are the "technical" ones, so I've never run Debian, because as far as I'm concerned, the whole and only point of a distribution is to make it easy to install (so that I can then get to the part I care about, namely the kernel), so Debian or one of the "compile everything by hand" ones simply weren't interesting to me.
Science Daily — Recent probes inside comets show it is overwhelmingly likely that life began in space, according to a new paper by Cardiff University scientists.
Professor Chandra Wickramasinghe and colleagues at the University's Centre for Astrobiology have long argued the case for panspermia - the theory that life began inside comets and then spread to habitable planets across the galaxy. A recent BBC Horizon documentary traced the development of the theory.
Now the team claims that findings from space probes sent to investigate passing comets reveal how the first organisms could have formed.
The 2005 Deep Impact mission to Comet Tempel 1 discovered a mixture of organic and clay particles inside the comet. One theory for the origins of life proposes that clay particles acted as a catalyst, converting simple organic molecules into more complex structures. The 2004 Stardust Mission to Comet Wild 2 found a range of complex hydrocarbon molecules - potential building blocks for life.
The Cardiff team suggests that radioactive elements can keep water in liquid form in comet interiors for millions of years, making them potentially ideal "incubators" for early life. They also point out that the billions of comets in our solar system and across the galaxy contain far more clay than the early Earth did. The researchers calculate the odds of life starting on Earth rather than inside a comet at one trillion trillion (10 to the power of 24) to one against.
Professor Wickramasinghe said: "The findings of the comet missions, which surprised many, strengthen the argument for panspermia. We now have a mechanism for how it could have happened. All the necessary elements - clay, organic molecules and water - are there. The longer time scale and the greater mass of comets make it overwhelmingly more likely that life began in space than on earth."
The new paper, The Origin of Life in Comets, by Professor Wickramasinghe, Professor Bill Napier and Dr Janaki Wickramasinghe is to be published shortly by the International Journal of Astrobiology.
Note: This story has been adapted from a news release issued by Cardiff University.