Search |
||
JSF 2.0: The Switchlist examplePosted by driscoll on November 29, 2008 at 11:05 PM PST
You've seen this component before: two lists, with buttons that let you move options from one list to the other. Here's what it looks like:
Now, we'll be looking at this for the next few blog posting, so I'm going to ask you to bear with me - this blog will just introduce the context for this component - I won't be showing any neat new JSF 2.0 features - that will happen over the next few days, while I build on what I'm showing here. So - two lists, two buttons. Here's the facelets code that draws these on the page:
If you've been following my previous blogs on this, you're not seeing anything new here: We include a style sheet using the h:outputStylesheet tag. There's some styleClass attributes that take advantage of that. We then use 6 different properties on a single bean - 4 values and 2 methods - to manipulate the model that's behind our switch list.
Here's the css:
Lastly, we have the model bean behind the switch list:
It's not important that we've got all this in one bean, of course - we could split it all up among several - what's important is that we're maintaining the state of the content of both lists (with the Put this all together, and you've got something that works in page, and reloads the entire page when you press either button. While this is fine, we're going to fine tune that a bit - starting with making this ajax enabled. Stay tuned - I'll have that up shortly. In the meantime, you can peek ahead by looking under jsf-demo/ajax-switchlist in Project Mojarra, and ask any questions below. »
Related Topics >>
Web Applications Comments
Comments are listed in date ascending order (oldest first)
Submitted by coding on Tue, 2008-12-02 11:56.
@ManagedBean... Is that webbeans or something new? Shouldn't we wait for webbeans before making this new annotation business?
Submitted by driscoll on Tue, 2008-12-02 13:48.
It's JSF 2.0, just as the rest of the features I'm describing here are.
Webbean will possibly be in Java EE 6, or not, depending on what the EE expert group says.
Regardless, there's no reason to not add annotations in JSF - unless you *like* xml configuration files.
Me, I don't care for them very much, and I'll be glad when they're gone.
|
||
|
|