ZK Custom Validation Style - java

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.

Related

How to use CellTable.Style with GWT 2.7.0 without UiBinder?

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();
}

Gwtbootstrap3. Using bootstrap component only with java code- without ui-binder

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!

Custom HTML parameters for component

When you use standard t:pagelink component you can pass arbitrary number of custom HTML attributes like class or some data attributes:
<t:pagelink page="somepage" data-somedata="test">link name</t:pagelink>
And they will be included in generated a tag:
link name
This does not work for components created by me. When I have:
<t:misc.custompagelink page="somepage" data-somedata="test">link name</t:misc.custompagelink>
The generated HTML looks like this:
link name
How to mimick the behaviour of standard t:pagelink component?
There are 2 ways to do this, both easy:
1) Read and follow the "Informal Parameters" section at http://tapestry.apache.org/component-parameters.html
2) Have your component class extend Tapestry's "Any" component (http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/Any.html)

intellij not resolving el variables within JSP code inspection or autocomplete

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>-

How do I make session/cache variables available to my main.html template?

I'm using Play Framework and setting a cache value as such:
String sessionId = Scope.Session.current().getId();
Cache.set(sessionId + "_user", "Doser");
and I want to ouput the value in my main.html without adding the value to every single controller in my application.
How do I achieve this in Play?
The other option you have for this, is to create an action in your controller that uses the #Before annotation, and then add the value using renderArgs().
I answered a previous question which I think is very similar to your requirements.
Does Play Framework support "snippets"?
You should also be aware that all session variables are available within your template, by default. You can see all the implicit objects that are available in the template in the Template Documentation here -- http://www.playframework.org/documentation/1.2.2/templates#implicits.
I need to stop answering my own questions.
I've created a tag as described in the link below, and it works perfectly:
http://www.playframework.org/documentation/1.2.2/templates#tags

Categories

Resources