I'm working on a project, that requires forms on page to be divided and put into separate tabs. Apache Wicket have very nice and simple way to do tabs by itself (TabbedPanel class), but my concern is, that this solution rely on AJAX for loading the content of the panels, hence the only one part of the form would be submitted after user presses "Submit" button.
I found a solution for simple CSS/JS tabs (http://www.barelyfitz.com/projects/tabber/), but I feel uneasy to use third party solution, and it is complicating my project (also, I'm not sure about the license).
What should I do?
There are several impls of TabbedPanel with JQuery which are completely JS/CSS based.
See wicketstuff's jquery integration project and WiQuery project.
The default TabbedPanel doesn't use AJAX. To use Ajax there is a own implementation (AjaxTabbedPanel).
This sounds very much like a wizard to me. Since wicket provides a wizard component to handle this kind of use case this might be a good point to look. Since I've not yet used this component I don't know how far it can be taken to display tabs but if it can't, it might at least give you the idea on how to build your own with tabs.
Related
Is there any header composite availabe in swt? What my requirement is I should have one user login form available in SWT. That form should be able to show inside the view. And that form should have one caption also. First I thought to use some kind of dialogs. But I dont want to
use any dialogs. Is there any way which I can implement the same?
There is an API called Eclipse Forms which was only introduced in Eclipse 3.3, so many books don't mention it. It lets you organize forms in a somewhat web-like way, with headers and sections and boxed groups and such. I think this would probably meet your needs.
Try to look at LoginDialog in Opal SWT Widget Library. It provide a ready-to-use and configurable login dialog. Maybe it will be suitable for you.
I'm making a game in java. Is there any way I can create HTML widgets for use in the game as the UI? It'd be great if I could attach some event handlers to the controls and fully use CSS, too.
You can use HTML and CSS for your game, but you'll need a servlet to handle requests.
Event handlers may be written in JavaScript, but they'll ultimately have to communicate with a server on the back end.
I know that this doesn't really anwer your question, but there is a library called Amino, that allowes you to use CSS to skin GUI components. That might grant you at least part of your wish.
"If there is a will there is a way"
If you're using raw Java instead of a framework that might give you some ready-made widgets, I believe you'll have to handle the HTML rendering yourself.
In Swing, one would look up class javax.swing.text.html.HTMLEditorKit for understanding how Java's JEditorPane renders basic HTML + CSS (the inner class HTMLFactory is particularly interesting as it creates the views that will render each HTML element). Perhaps this won't help you much, but maybe this would be a starting point.
Stanislav Lapitsky has done of a lot of work in Swing-HTML and gives tools that help you understand how to deal with HTML rendering. Check it out:
http://java-sl.com/about_author.html
Hey guys I have been trying different Javascript/AJAX jsf frameworks. I find most of them extremely heavy. Icefaces tends to add so much javascript just for simple things and it uses a notoriously slow javascript framework also. Primefaces is a little better since it uses jquery but I still find it kind of heavy. What if I just want to use straight vanilla jsf and add javascript on top of that.
What is the best way to go about this. I would need to be able to output javascript to the page from the backing bean. Would a servlet or restful service be good way to output javascript/html to a page?
I basically want to use basic jquery animations. Maybe do a datatable filter. Thanks for any help.
What you want is definitely supported in JSF. You can use the <h:outputScript> tags for this and additionally the <h:outputStylesheet> tag if you also need CSS.
With these tags you can include scripts per view (page), although you can also opt to include them for all pages by creating a master Facelets template and include those there.
You can also create very simple components of your own by using JSF/Facelet's composite component feature. Those components just consist out of a simple .xhtml template file and those can include the javascript libraries you need and contain your own lightweight tailor-made javascript.
See this for some examples of using the <h:outputScript> tag in JSF: http://www.mkyong.com/jsf2/resources-library-in-jsf-2-0/
I have a question on managing a multipage GWT website. For now I only have one html page in which I embed lots of divs to store the widgets that I use. Then, according to the user's actions I add or remove the necessary divs using GWTs DOM class. Therefore, I use only one html page to simulate multiple pages. Is there a better way to do this?
Thanks.
I disagree with cletus. In my experience, gwt is just as good at enhancing multipage apps as it is at one-page applications like gmail. It just depends on what you're requirements are for your web app.
I'd agree that writing one-page applications is definitely the place to start, but once you get the concept of gwt modules, they can easily be used to add custom javascript to multiple pages.
To answer your question; I think your design of using one page and swapping out widgets is perfectly acceptable.
These talks might help to give you ideas about when multi page apps might make sense:
Effective GWT: Developing a complex,
high-performance app with Google Web
Toolkit
Progressively Enhance AJAX
Applications with Google Web Toolkit
and GQuery
GWT is designed primarily for one-page applications. There is good reason for this. You take a hit every time you do a page transition with so much Javascript. The page load times are so noticeable. Think of goign to GMail. You have a period of 1-5 seconds where it loads. Now how would your user experience be if that happened whenever the user went to a new page and that happened a lot?
Neither do you need to put every widget on the page. You can dynamically create and add (or remove) widgets as you see fit. It's a somewhat different approach to how you'd normally do a traditional multi-page HTML-centric Website.
Something I have found useful is using the GWT DeckPanel. A deck panel is like a deck of cards where each "card" is a GWT Panel. You can treat these "card" panels like pages and initialise and populate them with widgets at startup. You can then respond to user navigation actions by bringing a "card" panel to the front of the deck so that the user can see it.
The sort of approach works best as part of either the MVC (model-view-controller) or MVP (model-view-presenter) design pattern.
In order to achieve such a thing, you should have history management - like Gmail, which can use back/forward. It is achieved by anchors, and this class
In addition to the good DeckPanel and History suggestions, I'd also add that you can get GWT to split your app into multiple JS files that are dynamically loaded as needed with runAsync. This let's you have a very fast initial page load and load the new "pages" as the user needs them.
LazyPanel.createWidget() is a convenient place to stick a runAsync call that can be combined with DeckPanel or TabPanel to dynamically load content and UI code. A controller/presenter for navigation is even better (though a little more work on the programmer sometimes).
I've never used Java before (C# is my domain), but now I have a task that I must apply a specific style to for a tiny Java webpage. The style is from another ASP.NET application that we're rolling out and that I've helped to develop. Seems that this style is on the way to become our new company web-style. :P
The webpage is really tiny - it has only a login form and an action form with a dozen textboxes and a button. When you click the button, a file is generated and available for download.
This application has already been made by a colleague of mine, who has good experience with Java, but nearly no experience with the web. So he's no help anymore. For now the application has NO style at all. Just a bunch of textboxes.
The application is made in NetBeans and Java Faces - as far as I understand. Or maybe it's "Visual Faces". Not sure - can't make heads or tails with all these names from the Java world. Anyway, it's this ASP.NET look-alike where you have an XML page with tags like <ui:textField> and <ui:passwordField>, and then a code-behind file with all your Java code. (Actually I suspect that ASP.NET was created after this, but that's besides the point)
I've successfully converted the HTML layout to the one I need and set my own CSS/JavaScript files in the header. There's just one problem - the Faces thing is hell-bent on including its own CSS stylesheets as well. Sounds reasonable of course, but for some mind-boggling reason these stylesheets also deem it necessary to override styles on all the common tags - <body>, <div>, <span>, etc. Which is annoying, because that breaks my design. Now, I could change my own stylesheets to over-override these default Faces stylesheets, but that seems... well, not the right solution. It's like a workaround, not a "correct" solution. Why should I redefine font attributes for every tag, when it should easily cascade down from the "body" tag?
Is there any way how I can tell Faces not to include its own stylesheets? I won't be using any of their controls anyway - just textboxes and buttons. And labels, when I find them. :P
Oh, yes, and I tried to re-create it all in simple JSP (no Faces), but that failed, because the code-behind (there's some big library there) is dependent on it... This is also the reason why I can't move it to the ASP.NET I'm so familiar with.
Added: Since it seems there are many Java Faces frameworks out there, here's a snippet of code that might help:
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<ui:page id="page1">
<ui:html id="html1">
<ui:head id="head1">
Also I forgot to mention that there is a folder in NetBeans called "Sun Web UI Components Themes" which has three items under it - "Gray Theme", "Green Theme" and "Default Theme". I can choose one of them as the active one, and that also changes the CSS which is included by default. Unfortunately I cannot choose none.
OK, I already changed my style to override these stylesheets. Still it would be nice to hear more about what I'm dealing here with. I don't even know where I should look for documentation...
Added 2: Also, the namespace for say, TextField, is com.sun.rave.web.ui.component.
Which JSF (JavaServer Faces) library is this using? MyFaces? RichFaces? Something different?
I don't know if you've found this resource yet: JSF Tag lib.
If it's using <ui: type tags, then it's also using Facelets which is a templating system for JSF. However the tag parameter you are probably looking for is styleClass and Style.
There really isn't a default styling for standard JSF, and I think there's probably another JSF library that's being used. Under the WEB-INF directory is probably a directory called lib where the jar files are. Those should give you a clue as to what library's are being used.
RichFaces comes with its own styling, and is completely themeable. In your particular case, it's going to be more of a pain than it's worth for your situation. Other JSF library's may do the same.
Unfortunately I can only point you at places and ideas of where the problem might be. Given the vast number of choices when it comes to JSF, it's the best thing I can do.