Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align items in a <h:panelGrid> to the right

Tags:

css

jsf

How would I align everything in my below to the far right?

<div id="container">    
     <h:form id="authenticate">
        <h:panelGrid columns="5" cellpadding="6">
             <h:inputText id="email" value="" />
             <p:watermark for="email" value="Email"/>
             <h:inputSecret id="password" value="" />
             <p:watermark for="password" value="Password"/>
             <p:commandButton id="login" value="Login" align="right"/>
        </h:panelGrid>
     </h:form>
</div>
like image 288
curiousgeorge Avatar asked Sep 15 '10 01:09

curiousgeorge


People also ask

How do I align an element to the right in HTML?

HTML | <div> align Attribute Note : This attribute is not supported by HTML5. Attribute Values: left: It sets the content to the left-align. right: It sets the content to the right-align.

How do you align block items?

To align things in the Block Direction, you will use the properties which start with align- . You use align-content to distribute space between grid tracks, if there is free space in the grid container, and align-items or align-self to move an item around inside the grid area it has been placed in.


2 Answers

The <h:panelGrid> renders a HTML table. You basically want to apply text-align: right; on every <td> element it renders. With the current code, easiest would be to apply the following:

#authenticate table td {
    text-align: right;
}

You can of course also be more specific, e.g. giving the <h:panelGrid> its own styleClass and defining a rule in CSS (which would be applied directly on the rendered HTML <table> element).

<h:panelGrid styleClass="className">

with

.className td {
    text-align: right;
}

You can also give each <td> element its own class by columnClasses attribute which accepts a commaseparated string of CSS classnames which are to be applied repeatedly on the <td> elements. If you want to apply the same class on every <td> element, just specify it once:

<h:panelGrid columnClasses="className">

with

.className {
    text-align: right;
}

As an extra hint: rightclick the webpage in webbrowser and choose View Source, then you'll understand better what JSF is all exactly generating.

like image 144
BalusC Avatar answered Nov 04 '22 04:11

BalusC


actually in same form i used <p:panel> and got good result. looks like ;

<p:panel  styleClass="ui-panel-titlebar ui-widget-header ui-helper-clearfix ui-corner-all">
    <p:commandButton value="Add New Tab"
            actionListener="#{xxx.createNewTab}" process="@this"
            update="tabView" style="float:right !important;margin:0px 0px 3px 0px;" />
            </p:panel>
like image 25
newuserua Avatar answered Nov 04 '22 05:11

newuserua