Tuesday, April 26, 2005

JSR 273 is born!

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


The
final vote
is in - and
JSR 273
has been born! The spec lead is my
colleague Joe Nuxoll, who also works on Creator. I
could have linked his name to his
blog here, but my
repeated
nudges for some blogging activity
don't seem to have any effect :-)



Briefly stated, the problem with the old JavaBeans spec is
that while it works, IDEs need a lot more information about
components - such as their context menus, etc., so every IDE
out there has gone and implemented their own abstraction on
top of JavaBeans. This means of course that components written
for one IDE don't work on another (or at least not the richer
integration aspects).



This JSR will address that, such that third party component
vendors (and open source developers) can write nice JavaServer Faces
components for one IDE and it will work nicely in other IDEs as well.



This JSR is near and dear to my heart. The Creator web page designer
(which I work on) deals with Joe's APIs heavily. For example, when
you drop a rowset from the Server navigator onto a dropdown,
there's no special knowledge in the designer about rowsets and
dropdowns. We simply rely on the enhanced component APIs to query
whether the target component accepts a link from the dropped component
and so on.



Now this is in the hands of the expert group and they'll start working
on a proposal. Perhaps it will be radically different from
what we've implemented in Creator today - but we'll track it and
make sure that down the road there's a strong component market place
on the Java platform.


Monday, April 25, 2005

AJAX

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


You've probably heard a lot about "AJAX" already. But if you haven't,
it's a new term describing technology which has been around for a while,
but has recently gotten a lot more popular because of some really well
done AJAX applications from Google:




AJAX is really a combination of technologies. The most important piece
is JavaScript code in the page making asynchronous requests to a server.
When the server responds it calls back into JavaScript, and this JavaScript
can then manipulate the content of the page directly.



Sun is working on this too; J2EE is an excellent platform for AJAX
applications. See
Greg Murray's Blog
for more on the blueprints project on java.net; AJAX blueprints are
available already with working sample web applications.
And perhaps more importantly, it includes

detailed documents
explaining how it all
works so you can take the blueprints and extend them for your own needs.



I find this technology really fascinating so I plan to blog more about it.


Saturday, April 23, 2005

Updatable Data Table

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


I was asked to show how a Data Table bound to
local data (as described here) can be updated.
Rather than try to describe it in further detail I just created
a simple Creator project. If you have problems in this area,
load the project and take a look.



Briefly, the project contains a single page, with a Data Table, a couple of text fields
and an Add button. When you press Add, the data in the textfields is used to create a new
Person object, this person is put into the master list of people (maintained in the Session bean),
and the data table is updated to reflect the change.


Friday, April 22, 2005

Centering Components

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


The issue of centering components has
come up
several
times before, but I don't think I've actually described in detail how to do it.



The problem is this:


How do you center a component in the page, such that the components appear in the dead center of the browser window,
regardless of the size of the user's browser window?



Obviously, the answer is that you do this with CSS. But how? The canonical answer is to use auto margins. Set the width of the components, and set left and right margins to "auto", and the component will be centered. However, it's not -quite- that simple (for example, on IE5 you need to use text-align: center, and once you do that you need to add in other CSS to counteract that bad side effects.)
Furthermore, what if you want to vertically center the components too?






A solution for this is actually pretty simple. Briefly, the trick is to use absolute positioning to compute the dead center of the page;
doing that is easy:


position: absolute;
left: 50%;
top: 50%;


But of course that will center the top left corner of your component, not the center of your component. But you can use negative margins to achieve that!



First, you need to decide the width of your component. Let's say it's 200 pixels wide, and 80 pixels tall. In that case, position the component in the dead center, and then subtract half of the width and half of the height such that the center of the component
is centered. In our example, half of 200 is 100, and half of 80 is 40, so we add the following section to the <head> of the page:


<style>
.centerPanel {
position: absolute;
top: 50%;
left: 50%;
width: 200px;
height: 80px;
margin-top: -40px;
margin-left: -100px;
}
</style>

Now you just need to set your component's styleClass attribute to centerPanel (no dot) and it will
be centered.



For example, to make a Login panel centered in your login page, drop a Grid Panel. Drop an Output Text and set its text to "User Name:", drop a Text Field, drop another Output Text (set to "Password:") and drop a Secret Field. Set the Columns property to "2" (such that User Name and its Text Field are on the first line, and Password and its password field are on the second). Now either add the above styleclass definition to your stylesheet, or set the style property to the contents of the above styleclass (position: absolute; top: 50%; ...). Voila - your text should be centered in the page - even when the user resizes their browser page.



Experiment with adding additional CSS properties to set a frame for your Grid Panel to make a border; for example


border: solid 1px gray;
padding: 10px;


Chat Transcript Available

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


The transcript
from the recent Creator chat is now available.
As you may recall, we had some technical problems
with the chat software, so a couple of questions were lost and had to
be reconstructed from memory...



I realize I promised to write a companion blog to the
tabbed menu blogs.
Sorry... it's still on my TODO list... I need to think a little bit about it. Doing a navigation menu
should be extremely similar to the tabbed menu (you simply change the orientation of the Grid Panel
used in the tabbed menu, and change the CSS such that rather than tab appearance each cell is simply
a menu item). Therefore, I assume people who wanted a blog on this want something more advanced - perhaps
popup JavaScript or something like that.


Just getting better and better

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


First, Happy 10th birthday, Java! Unfortunately I was unable to attend the Birthday Party...



The "Gray Rectangle" issue in Swing has been fixed! This is the problem where you'd for example hit the "Finish" button on some dialog
in a Swing app, and for a second or two the screen would show a gray unpainted rectangle where the dialog was just dismissed
while the app is computing like mad. No more. Swing now (as of recent Mustang (JDK 6) builds)
does true double buffering, so it will restore the previous window contents immediately even if the AWT thread is busy.
You can read more about this in
Scott Violet's blog. And check out
all the other nice improvements
happening in the Java desktop area.



Speaking of Swing applications, NetBeans has released a
4.1 release candidate
. You should definitely give it a try. It has a number of really nice improvements from 4.0, such
as the navigator, or the jump to declaration hyperlinks, or lots of usability fixes - see Roumen's blog
here,
here
and here for example.
To be honest, I don't actually use the RC build - I like to
build the IDE from source myself. That way I can live on the bleeding edge - and use some of the
new features in the pipeline, such as the editorhints.






And speaking of NetBeans, there's going to be
a NetBeans Day this year
right next to JavaOne. Check out the speakers! Note also that the event is free, so you don't need to be registered
for JavaOne to attend.



Finally, check out this Microsoft blog
from somebody on Internet Explorer team. Despite some earlier public comments which indicated that
IE was focusing on browser features (like tabbed browsing) and not web standards compliance, Chris is saying
that the annoying PNG transparency bug has already been fixed, and that other important CSS bugs are also being addressed.
That's really great news. I'm speaking from direct experience here, having just spent two hours trying to get
something which was working on Firefox, Safari and Opera to work correctly on IE. That's for a hobby project
I'll blog about in the next couple of weeks - so stay tuned!!


Friday, April 15, 2005

JavaServer Faces Improvements

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


See
Ed Burns'
latest blog entry to read what's coming in the JSF 1.2 release.