How to display image button inline with text in a table cell? - css

I have a JSF 1.2 dataTable using ICEfaces 1.8. In one column, I would like to display the text from a backing bean, and then to the right of it, display a small image on the same line without it wrapping to a new line.
The image is actually a ice:commandButton component with the image attribute set. The action of clicking on the image is to display a ice:panelPopup panel.
Here is the relevant code of the column within the dataTable:
<ice:column id="col1">
<ice:outputText escape="false" value="#{document.column1Value}" />
<ice:form>
<ice:commandButton actionListener="#{bean1.open}" image="images/popup.gif">
<f:attribute name="docParam" value="#{document.parameter}" />
</ice:commandButton>
...
</ice:form>
</ice:column>
I have tried all sorts of adding CSS style information to various tags, including white-space:nowrap and float but have been unable to get the desired effect.

The <ice:form> generates a HTML <form>, which is by default a block level element, so it always starts at a new line. You need to set the style of the <form> to display: inline.
<ice:form style="display: inline;">
Alternatively, you can also just move that text into the form.
<ice:form>
<ice:outputText escape="false" value="#{document.column1Value}"/>
<ice:commandButton actionListener="#{bean1.open}" image="images/popup.gif">
<f:attribute name="docParam" value="#{document.parameter}" />
</ice:commandButton>
...
</ice:form>
Either way, you only still need to prevent the cell's content from being whitespace-wrapped when there's little room left in the cell's width. You could achieve that by setting white-space: nowrap on the common parent element of the both elements. In case of the first approach (setting the form to display: inline), that would be the <td> element and in case of the second approach (putting the text inside the same form), that would be the <form> element. E.g.
<ice:form style="white-space: nowrap;">
<ice:outputText escape="false" value="#{document.column1Value}"/>
<ice:commandButton actionListener="#{bean1.open}" image="images/popup.gif">
<f:attribute name="docParam" value="#{document.parameter}" />
</ice:commandButton>
...
</ice:form>
(note, the style attribute is in the above examples exemplary, in real you should be using CSS files instead with style classes)

Related

Phrasing content with changed display property in CSS

In the <button> specification part we see that permitted content is only Phrasing content. It's valid HTML code part (checked here):
<button>
<span></span>
</button>
This is not valid HTML code part (checked here):
<button>
<div></div>
</button>
Error: Element div not allowed as child of element button in this context. (Suppressing further errors from this subtree.)
But we can change display property of the <span>:
<button>
<span style="display: block"></span>
</button>
And it looks like we use a <div> instead a <span>, but the HTML is valid. Is it OK (by the specification) to use a permitted content element and change its display property?
Even though you style a span with display: block you still can't put block-level elements inside it:
<div><p>correct</p></div>
<span style="display: block;"><p>wrong</p></span>
The (X)HTML still has to obey the (X)HTML DTD (whichever one you use), no matter how the CSS alters things.
So they are different, and thus there is nothing problematic here.
But in HTML5 some block elements may be placed inside inline! we say about putting block elements inside link and in other cases it doesn't have sense. “Block-level” links in HTML5

CSS selector for a label wrapped around a particular control?

I have this label and checkbox
<label><input type="checkbox" id="SameAsPrimaryAddress" />Same As Primary Address</label>
Is there a CSS selector that will only affect the label text and not the checkbox or do I have to separate my label from the input or give the label an ID or class to be able to do this?
It depends
In that case and if you only need that HTML, you can.
But
It is better to wrap your text with a span or a div to avoid problems you can encounter.
Here's a demo
http://jsfiddle.net/6aS4k/
Then you can add style with label span {}
Your answer: No. There is no selector to only target the free floating text of an element, without affecting the inherited properties of other elements within. To explicitly style your text, you would actually want to wrap your text in another element to target in your CSS, like a span.
However, in your specific case, that checkbox does not have many (if any) inherited properties in most browsers default stylesheet. So, a long as you aren't using a reset stylesheet or otherwise normalizing that input to inherit style properties you could get away with styling the label to affect only the text.
In the end, I would recommend that your label should actually correspond to your input separately, which would also semantically make sense. This would also allow you to make use of the for attribute, which will allow clicking on your label to toggle the corresponding checkbox as well, which is a win for usability!
<div>
<input type="checkbox" id="SameAsPrimaryAddress" />
<label for="SameAsPrimaryAddress">Same As Primary Address</label>
</div>

CKEditor nested paragraphs issue inside custom block style div not displaying properly

in the custom styles inside CKEditor, I have created a "Tip" block element that I want to have span one or more paragraphs. However, when I am editing my text (using the inline editor), I am unable to get the block style to work across multiple paragraphs.
My style looks like this:
CKEDITOR.stylesSet.add('authorStyles', [
// Block-level styles
{
name: 'Yellow Tip',
element: 'p',
styles: {
margin: '1em 0',
padding: '20px 20px 4px',
border: '1px solid',
'border-radius': '15px',
'background-color': '#FFC',
'border-color': '#CC9'
}
}
]);
In the config.js, I added the line to wire-up the custom style
// custom styles
config.stylesSet = 'authorStyles:../authorStyle.js';
And here is my HTML:
<div class="section right" contenteditable="true" id="contentToSubmit">
<p>Here we have some addtional content that is also editable as well in addition to being just some text on its own right.</p>
<p>Here we have some addtional content that is also editable as well in addition to being just some text on its own right.</p>
<p>Here we have some addtional content that is also editable as well in addition to being just some text on its own right.</p>
<p>Here we have some addtional content that is also editable as well in addition to being just some text on its own right.</p>
</div>
Unfortunately, when I select two paragraphs to be contained in my div, they both display as their own blocks, instead of both <p> tags being inside my custom <div>.
Paragraphs not displaying properly inside custom block style div
I tried resetting the default enter key behavior (via the enterkey extra plugin), but the only thing I could get to work is setting the enter key behavior to line break (<br/>) which isn't desirable.
I have looked around for help on this particular issue, but can't seem to find an article that deals with this problem. Can anyone help me? We are trying to determine whether ckeditor will be sufficient for our needs, but this is a big blocking issue for our content editors.
The short answer is:
Defined your style as a div style, because you want it to apply to divs not ps, right? So you should have: element: 'div'.
Instead of applying the style through styles combo, what will replace paragraphs with divs, use the "Div" button to open the "Create Div Container" dialog and choose your style in the dialog.

How to apply css on acefaces datatable and also minimize its width

Here is my acefaces datatable
<ace:dataTable id="tbl" value="#{mainSearch.searchResult}" var="srvc"
paginator="true" paginatorPosition="bottom" rows="10"
emptyMessage="No Record Present Yet" rowsPerPageTemplate="10,25,50,100"
rowIndexVar="row" rowStyleClass="#{row mod 2 eq 0?'none':'skyBlue'}">
<ace:column headerText="Category" sortBy="#{srvc.groupName}"
filterBy="#{srvc.groupName}" filterMatchMode="contains">
<h:outputText value="#{srvc.groupName}"/>
</ace:column>
<ace:column headerText="Service Number" sortBy="#{srvc.serviceNumber}"
filterBy="#{srvc.serviceNumber}"filterMatchMode="contains">
<h:outputText value="#{srvc.serviceNumber}"/>
</ace:column>
<ace:column headerText="Shift" sortBy="#{srvc.shift}"
filterBy="#{srvc.shift}" filterMatchMode="contains">
<h:outputText value="#{srvc.shift}"/>
</ace:column>
</ace:dataTable>
Now this datatable is showing on my whole page.I can fix its height by <ace:datatable height=.. but I didn't find any width attribute.I also tried to set its width using CSS (using style attribute on both header, datatable) but it didn't work. Now I am stuck here and unable to find that How can I minimize its width.
Note: The only way that worked for me was to small the header text.For instance, As my first row header is Category.Now If I repalced it with just CAT then whole row gets shrink.It mean first of all I need to squeez the text(as it is my guess).Is there anyway that without poking this text? If not, then how can I resize this text and shortened this datatable?
I've tried altering CSS width property in Firefox of the ICEfaces showcase, achieving the result you want. Note that there may be some potential problems when you make the table too small and the data won't fit in the table anymore, so my advice will be to inspect the resultant table in the browser to get the right CSS fixture.
Regarding the documentation of <ace:dataTable>, there are the typical styleClass and style property for setting CSS style classes and inline style respectively, so the following will do the work:
<ace:dataTable style="width:80%"> ... </ace:dataTable>
or
<ace:dataTable styleClass="my-width"> ... </ace:dataTable>
with CSS class:
.my-width {
width:80%
}
As a side note, when you are ready to try out the latest Primefaces <p:dataTable>, you will find many attributes designed for setting up proper CSS styles.

Set a Grid next to another in a gwt Page

What kind of styling should I set to two Grids in order the one to stand next to the other? In the way I have created them in the xml file, the second stands below the other and it does not comply with the style of the general Page:
<div>
<z:StaticDataGrid ui:field="staticDataGrid" />
<z:DataGrid ui:field="displayedDataGrid" />
</div>
StaticDataGrid and DataGrid are class representing Grid.
Place the grids inside a HorizontalPanel to place them side by side.
<z:HorizontalPanel>
<z:StaticDataGrid ui:field="staticDataGrid" />
<z:DataGrid ui:field="displayedDataGrid" />
</z:HorizontalPanel>

Resources