Struts 2 HTMLissue when using <s:doubleselect> - java

I am using <s:doubleselect> in my jsp. The problem is both come on different row while I want the in same line. Here is the code
<s:doubleselect theme="css_xhtml" labelposition="top"
requiredposition="left" name="index" cssClass="dropdown_menu" list="#request.constants.keySet()"
doubleList="#request.constants[top]" doubleName="oldValue"
doubleCssClass="dropdown_menu" ></s:doubleselect>
How it can be possible to put them on same line?

This behavior is an unfortunate holdover from the old UI tags.
The easiest solution is to use CSS to change <br/> styling inside the .wwctrl class (changes all controls, which may be what you want anyway):
.wwctrl br {
display: none;
}
A less-practical, but potentially cleaner, solution would be to extend the theme and tweak the control's template. There are a number of controls that have some questionable HTML, but hardly anybody uses the specialized controls, so we never fix them.

Related

Why is zk rendering a second tbody for a listbox?

I'm having a problem where zk 3.6.3 is rendering a second <tbody> tag for a Listbox. Actually the first rendered <tbody> tag is the one that is making me problems. It has it's css style set to visibility:hidden;height:0px and Opera 12 and IE 11 are rendering a large white empty space for it. So in the browser I see the table header, this empty space and then the actual rows of the listbox.
The problematic code for zkoss rendering is contained in org.zkoss.zkmax.zul.render.ListboxDefault in lines 53-63.
How can I prevent zkoss or browsers from rendering this empty space?
Well, there is always a solution and maybe the "hacking" solution is the best here :
Class overriding of that class.
Create that package and create that class (exactly the same package and classname).
Copy the code from your link to your class.
Change the code, I'll suggest try to remove the complete if. => See what result it gives (test al your listboxes!)
When you ever think of upgrading ZK version : Don't forget to remove or update the class !!!
If removing doesn't help, try to change the style,...
On the other hand, if updating ZK version is possible, you should try that.
The version you use is old, and doesn't support newer browsers.
The first tbody contains the list header (no, I don't know why they don't use thead for this). If you don't add one to the list, the CSS visibility:hidden;height:0px should make it invisible on the screen and that works for me.
My guess is that somewhere in the app, you have CSS rules which override this style. So the next step is to fire up the web developer tools and check which CSS styles are actually applied.
Alternatively, you can give the list box a custom class setSclass("hiddenheader") and then use CSS like this:
table.hiddenheader tbody:first-child { display: none; }
(note: I didn't test this; ZK might add some prefix to the styles so you might have to adjust the code but the example should get you started).

How to swap out widget element based on data

We have a GWT project using RequestFactory, Editor Framework and UiBinder. Once the data is loaded from the server using RequestFactory, we determine whether the page should be read-only based on a status in the data.
At this point I would like to render either an input widget or a label (if read-only).
Ideally I would swap out the rendering of the widget depending on the data, however by the time that the data is loaded it looks like the rendering side has been completed (based on debugging I've done).
I don't want to have two widgets on the page with one hidden. This has caused us issues already with data from the hidden one overriding the other, not to mention the impact of twice the number of widgets in the DOM.
One thought so far was to removeFromParent() when the data was received. Is there a better way to do this?
Thanks.
My first idea is...
Only works for input fields and textareas. If you have dropdowns, radioboxes or checkboxes it doesn't work...
...to style an input field via css so it doesn't look like one (remove border and background color should do it) and disable it if its read only. If its not read only remove the css class, so it looks like a normal input field and make it editable.
Something like this:
<style>
.label {
background-color: white;
border: 0px;
color: black;
}
</style>
<input type="text" class="label" disabled value="Read only data"/>
<input type="text" value="Editable data"/>
An other idea is..
It has been some time that I was using GWT. But can't you just add the widget in the callback from the rcp call where you get the data?
Something like this:
In the ui Binder you just have the container for the data.
In a method you draw the Data as Label or Input field in the container, depending on the data you get. You call this method in the callback from the data request.

CSS style for radios in Tapestry 5

How can I get rid of the box look of radio buttons in IE8? They look like this:
They look normal in other browsers. I'm using Tapestry 5.
Thanks.
It sounds like you have a border around all INPUT tags which most likely comes from your own css somewhere as I don't believe tapestry adds it by default.
Adding this to your css should resolve it.
input[type="radio"] {
border: 0 none;
}
If it doesn't, you'll have to share your html and your css so we can have a closer look.

Understanding Tapestry Principle 1. "Static Structure, Dynamic Behaviour"

I'm learning tapestry 5 web framework but I don't understand the principle 1 about it:
"Static Structure, Dynamic Behaviour", what does means it ?
If I don't add components to the components, how can I create a dynamic page?
anyone can help me?
Thanks in advance
It means that you can't choose or replace components at runtime effectively.
If, say, you'd want to build a portal solution where users could arrange components on a screen any way they wanted, Tapestry would not offer an effective way to do that, because components have static structure, i.e. you must define what goes into them at compile-time in their template file.
Or you might have a specialized menu for administrators, so you might want to just replace the Menu component with a derived component, AdminMenu - but you can't, you have to use if statements in the template or use a block to inject different menus into your layout component.
There's an anti-pattern related to this limitation: The God or über-component tries to solve this problem by effectively having a giant template file with all the available components, like this:
<t:if t:test="displayComponentA">
<span t:type="ComponentA" ... />
</t:if>
<t:if t:test="displayComponentB">
<span t:type="ComponentB" ... />
</t:if>
...
This, however, is horribly ineffective, as Tapestry assembles the entire component tree, including components that are not displayed, to do the rendering of the page.
Tapestry uses templates to define static content. These templates are usually html pages with placeholder variables which are replaced by some code dynamically by the framework. Templates allow for segregation of things that not change from the ones that change. Usually structure is less prone to change then behavior. Even if you want to change some element of a component dynamically you're going to use some component that itself is defined by a template that is dynamically filled with data. This dynamic data again can insert some other component etc.
Static structure doesn't mean that you cannot output dynamic content nor that you cannot add components to components. You just cannot add a component to another at runtime. You can define a page or component structure using other components, but this is all defined in the template, before the page is rendered, never while it's rendered. A component can choose not to render itself, to render part of its template (If and Unless components), etc.
One of the few practical situations caused by the static structure of Tapestry is that a component C cannot use another instance of the same component inside it.

struts focus on field after validation without js

i'm using struts (form) + validation
i just want to ask if can i set focus on some field on form after validation without javascript? i think i red something in book programming jakarta struts but i can't remember.
thanks
You cannot set focus on a certain field with pure HTML. The tabindex idea as suggested by Bozho is nice, but it will only work if you actually press tab for the first time. It has however the disadvantage that it changes the tabbing order of the input elements. Not really user friendly.
You'll really need to grab JavaScript for this. Just do something like:
window.onload = function() {
document.formname.${inputname}.focus();
// or:
document.getElementById(${inputid}).focus();
};
...where ${inputname} dynamically resolves to name of the input field as in <input name="foo"> and where ${inputid} resolves to ID of input field as in <input id="foo">.
That's all.
You can set the tabindex="1" attribute of the input which you want to have obtain the focus first, when the page reloads.
You can't set the focus on a field without using JavaScript. Others have tried and failed (CSS was the first place they looked at, but that doesn't cut it either).
Not sure what you've read in the book Jakarta Struts, but maybe you are referring to the focus attribute of the Struts <html:form> tag? That sets the focus on the desired form field without you needing to add JavaScript. But Struts will add the JavaScript, so that means no JavaScript from your side, and not no JavaScript at all.

Categories