I joined a GWT application project a few weeks ago. The codebase was started back in 2009. I am trying to replace a FlexTable with a CellTable so that I can take advantage of the sortable columns. The current version of GWT in the project is 2.7.0, but looking through the code, it looks like there are some features still used that have gone out of style. I am new to GWT, I could be wrong.
So far, things are functionally good. However, GWT seems to be overriding my attempts to update the CSS. I used the GWT dynatablerf sample as a model to add CSS to the CellTable. The TimeSlotWidget uses CellTable.Style:
interface TableResources extends CellTable.Resources {
#Override
#Source(value = {CellTable.Style.DEFAULT_CSS, "CellTablePatch.css"})
CellTable.Style cellTableStyle();
}
And then applies it to the CellTable like this:
table = new CellTable<TimeSlotListWidget.ScheduleRow>(ROWS_IN_A_DAY,
GWT.<TableResources> create(TableResources.class));
I tried to use this approach in my code. I even omitted the CellTable.Style.DEFAULT_CSS from the value list and created my own CSS stylesheet which started as a copy of the GWT CellTable.css
I noticed that GWT TimeSlotListWidget sample has an ui.xml file with UIBinder. My project does not currently use UIBinder.
When I run my code, there is a <style> block inserted into the page that seems to be the standard GWT CellTable.css. Then directly after that, another <style> block is inserted with my CSS. And my CSS is not overriding the standard GWT CSS.
How can I keep the GWT CellTable.css from being inserted? Why is it being inserted?
The problem is that in your code, you reuse CellTable.Style, and two different ClientBundles have used the same type but each bound their own CSS to it.
Instead, extend the CellTable.Style interface, and use that in your bundle:
interface MyCellTableStyle extends CellTable.Style {}
interface TableResources extends CellTable.Resources {
#Override
#Source(value = {CellTable.Style.DEFAULT_CSS, "CellTablePatch.css"})
MyCellTableStyle cellTableStyle();
}
Related
Is there possibile to use bootstrap3 elements (from gwtboostrap3 library) without using ui binder, but using java code like it is done with gwt regular widgets?
I could not find a word about it in Documentation.
F.E. Lets take button widget from gwt:
public void onModuleLoad() {
// Make a new button that does something when you click it.
Button b = new Button("Jump!", new ClickHandler() {
public void onClick(ClickEvent event) {
Window.alert("How high?");
}
});
// Add it to the root panel.
RootPanel.get().add(b);
}
}
Which will create:
<button type="button" class="gwt-Button">Jump!</button>
In gwtbootstrap3 I have to do something like that:
<b:Button type="DEFAULT"/>
Please help me with that.
Is it possible to use gwtbootstrap3 library components like button with pure java instead of uibinder xml files?
Is there solution that works out of box?
Or maybe I should write my own classess that extends native gwt widget an add bootstrap releated css classes?
Yes!
You can use the widget as you please, refer to the their javadoc to see what constructors they have! They are a different set of widgets and might not be analogue of GWT standard widgets.
Bonus
GWT UiBinder does no different than you, all it does is reduce the boilerplate, generating java classes that automate the instantiate of the widgets. You can add the compiler option -gen to see these transient classes. Usually , they are deleted after GWT compiles your application, as they are no longer needed. Take a look the the compiler documentation for more info!
As the title says I need some help with GWT's i18n in use with UiBinder. I want to internationalize my application using static i18n. The book I use for learning only presents a way of internationalizing ui.xml files by having the compiler generate keys for Constants/Messages and a default file, but there has to be an easier way to do this. That's why I tried using the ui:with tag like this to use my internationalized constants (inside the upFace):
<ui:with type="havis.ui.shared.resourcebundle.ConstantsResource" field="lang"></ui:with>
<g:ToggleButton ui:field="observeButton">
<g:upFace>{lang.observe}</g:upFace>
<g:downFace>Observing</g:downFace>
</g:ToggleButton>
This doesn't work, the button shows the text {lang.observe} which also seems logical, but now my question is: Is there any way to use constants like this? And if not could someone explain how I should use constants in UiBinder files instead (without having the compiler generate files and keys)?
Anywhere HTML is accepted (such as within upFace), you can use <ui:msg>, <ui:text> and <ui:safehtml> (and anywhere plain text is expected, you can use <ui:msg> and <ui:text>).
So in your case:
<ui:with type="havis.ui.shared.resourcebundle.ConstantsResource" field="lang"></ui:with>
<g:ToggleButton ui:field="observeButton">
<g:upFace><ui:text from="{lang.observe}"/></g:upFace>
<g:downFace>Observing</g:downFace>
</g:ToggleButton>
See http://www.gwtproject.org/doc/latest/DevGuideUiBinder.html#Hello_Text_Resources and http://www.gwtproject.org/doc/latest/DevGuideUiBinder.html#Hello_Html_Resources about ui:text and ui:safehtml.
You can use constants like this :
.ui.xml :
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'>
<ui:with field="constants" type="my.client.resources.AppResources.AppConstants"/>
<g:FlowPanel>
<g:Label text="{constants.label}"/>
</g:FlowPanel>
and the AppResources interface :
public interface ApplicationResources extends ClientBundle {
public static final ApplicationConstants CONSTANTS = GWT.create(ApplicationConstants.class);
public interface ApplicationConstants extends com.google.gwt.i18n.client.Constants {
#DefaultStringValue("my label")
String label();
}
}
But for i18n you should really follow what the GWT manual says, i.e. there
is no other (clean) way than prepare all the property files (one for each language) and generate all the required permutations. This primarily delegates
to GWT all the language detection-related stuff, and the solution provided by
GWT performs quite well at runtime. The only drawback is that the compile time
is a little higher (since you'll have permutations for every browser in every language you specify).
Is there a way to style the validation message (WrongValueException etc.)
Because it is absolutly not touch friendly.
I searched in the docs of zk but i found nothing.
Currently I use Zk 6.5.2
The validation messages are displayed in an ErrorBox widget.
The z class is z-errbox. Unfortunately, I don't believe ZK gives you a hook to specify a custom z class for any particular ErrorBox. This means the only way to override the style for an ErrorBox is to override the style for all ErrorBoxes. It sounds like that might work for you, if so, you can see the the ZK style class definitions in the source code.
For example, you could override the validation text color with..
.z-errbox-center {
color: blue;
}
As a side note, you'll probably want to hook your custom CSS file into ZK rather than manually loading it on the page. This will ensure it gets loaded as fast as possible and the user won't see the styles change as the page loads.
(in WEB-INF/zk.xml)
<desktop-config>
<theme-uri>/css/style.min.css</theme-uri>
</desktop-config>
You can read more about the theme-uri tag in the documentation.
I have created a JavaFX application, I have built native bundle using Ant, and I am obfuscating jar with Proguard-4.8.
I am able to create native bundle exe using that obfuscated jar successfully. When I run it, it launching the application successfully, All things are working fine, but there ia one problem in TableView. That is data are present in TableView, but I am not able to see data in TableView.
Below the screen shot taken from exe for TableView is attached -
Is there any extra settings or code changes needed in class which are mapped to Tableview for data association, at the time of obfuscating.
I am getting my own way
I use the long form of PropertyValueFactory :
col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Test, String>,
ObservableValue<String>>() {
public ObservableValue<String> call(TableColumn.CellDataFeatures<Test, String> t) {
// t.getValue() returns the Test instance for a particular TableView row
return t.getValue().testProperty();
// or
return new SimpleStringProperty(t.getValue().getMessage());
}
});
if you use "PropertyValueFactory " for the table, you should keep the Your_Object class from obfuscation. If you do not do that, the PropertyValueFactory cannot search the Your_Object after obfuscation because this object is obfuscated.
Please find the specification of the PropertyValueFactory class from Oracle at:
PropertyValueFactory specification
Imaging you have already buildup so many tables in different packages then you need to change all.
No I suggest using this in you proguard_config will help
-keepclassmembers public class yourpackage1.**, yourpackage2.** ,yourpackage3.**{
public javafx.beans.property.StringProperty *Property();
}
To summarize the answer shown here Code assist in (jsp /jstl) view for Spring MVC model objects in Eclipse
is not working for me at all, is there a setting that I need to change ?
I have just downloaded the sample spring-mvc-showcase on github, and it doesn't work out of the box on that project (with either 11.1.3 or EAP 12 version both full enterprise editions), see below (I have no idea where it gets formBean from) :
Here is an example from my own project,the screen shot below (bottom frame) shows my controller adding a string attribute to model and returning correct view name. I would then expect shopString to be offered up as autocomplete option when editing that view, however it is not :
sg is a javascript variable - so great it should be there, but where is "shopString" ?.
Is there a setting I need to change or something else I am missing to get this functionality (using 11.1.3 enterprise edition with all the spring plugins).
It is also failing on spring specific variables :
IS their an open source (one of the spring tutorial projects?) where this definitely works ... or is there a setting I need change in my Intellij install (I have tested with a brand new download of the version 12 EAP) ?
One more screenshot below shows all my spring coifg files set up correctly via autodetection, but the code inspections fails ... this is the spring-mvc-showcase project :
There's a standard way to do this, which is not IntelliJ-specific.
<jsp:useBean id="someModel" scope="request" type="foo.bar.SomeModelClass"/>
The type attribute here does not need to be a concrete class, it can be an interface type as well. Typically you'd put these declarations at the start of your JSP/JSPX files, to provide something like a "declaration of model inputs".
Using JSPs in such a declarative way was recommended in the original book on Spring, in fact (Expert One-on-One J2EE Design and Development.). IntelliJ has been providing full code completion for such pages since at least 7 years.
Note that there are additional relevant convenience features in IntelliJ: if an EL variable reference is marked as undefined, you can press Alt-Enter to select a QuickFix, which will insert a declaration like above. It will even try to figure out the actual type, based on the properties you're accessing.
As I understand Spring, there is no declaration for definitions of variables that you may put into your model. The call model.addAttribute() may add an object to the model, either identified by a parameter or automatically generated by the class name of the object.
So imagine the following case where you have more than one method:
#RequestMapping("foo") public String foo(Model model) {
model.addAttribute("model", new Foo());
return new Random().nextBoolean() ? "page" : "someOtherPage";
}
#RequestMapping("bar") public String bar(Model model) {
model.addAttribute("model", new Bar());
model.addAttribute("model", new Foo());
model.addAttribute("model", new Bar());
return new Random().nextBoolean() ? "page" : "someOtherPage";
}
and the JSP would be something like
<c:out ${model.value} />
Since there is no proper mapping of which controllers may under some circumstances forward to which views, nor what exactly lies within the model, your IDE has no real chance to provide you with proper information.
But to support the IDE in suggesting you some useful information, you can use type hints. Therefore, you have to copy the whole reference of an object, e. g. foo and add a JSP comment like:
<%--#elvariable id="foo" type="com.mycompany.SomeObject"--%>
The warning will vanish and the full IDE support is on your side, allowing you to traverse the fields of foo.
One of the nicest things is that the unused getter warnings will vanish, too. You can directly call the show usages action directly from the JSP or the POJO.
This also works with JSF and particularly within JSF components. Pretty neat feature to have this kind of code completion, showing warnings and errors.
Hope that helps you with your switch to Intellij Idea.
Edit: I also reported this finding to a friend wo wrapped the whole thing into a nice blog entry. Maybe you're interested in reading it: open link
This got fixed in the latest release of intellij 122.694
I faced with similar issue when start writing my own interceptor. Problem was that I start using refference in my view resolver configuration
don't use contruction like this
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" ref="prefix"/>
<property name="suffix" ref="suffix"/>
</bean>-