primefaces style apply only to nested elements - css

For removing the padding inside a Tab of the Primefaces TabView component, I created a new style on my css file:
.tabviewleft .ui-tabs .ui-tabs-panel {
padding: 0px 0px;
}
Then I tryed to apply this new style to the Tab. But it didn't work:
<p:tab id="fieldCategoryTab" title="category" styleClass="tabviewleft" >
Then I tryed applying on the TabView component. But it didn't work too:
<p:tabView id="tabViewLeft" styleClass="tabviewleft">
Then I created a div outside the TabView and it worked:
<div id="teste" class="tabviewleft">
Why I need to create a div outside the TabView to apply the style?
Is it possible to apply it directly to the Tab or TabView without creating a div?
Thank you in advance for any explanation.

Yes it is possible .
Suppose your <p:tabView>'s structure is like :
<p:tabView id="tabView" styleClass="tabView" dynamic="true"
cache="false">
<p:tab title="#{trhBundle['paidLeave']}" id="paid">
<h:form>
</h:form>
</p:tab>
<p:tab title="#{trhBundle['RTT']}" id="rtt">
<h:form>
</h:form>
</p:tab>
<p:tab title="#{trhBundle['specialLeave']}" id="special">
<h:form>
</h:form>
</p:tab>
</p:tabView>
Then add css
.tabView .ui-tabs-panel {
padding: 0px!important;
}
I think this will remove all padding of <p:tab>.

Related

PrimeFaces menubar, last menuitem on float:right

i have this menubar in my project, i'm using PrimeFaces for the first time:
<p:menubar styleClass="sso_header ui-widget-header " style="width:99.5%; margin-top: 3px; border-radius: 10px;" >
<p:menuitem value="Test" rendered="true"
style="border: 1px solid; margin-right: 5px;" icon="ui-icon-triangle-1-s" />
<p:menuitem value="LOG IN" rendered="true"
style="border: 1px solid; margin-right: 5px;" icon="ui-icon-triangle-1-s" />
</p:menubar>
I need last menuitem float:right;, at least I tried to include external style in this way:
<h:outputStylesheet name="css/style.css" />
and assign my css class to the menutitem.
I tried inline style whit the !important attribute, nothing works.
After inspect code from browser i noticed that Primefaces assign my style to a <a> inside a <li>.
There is a way to assign float right to that <li> in PrimeFaces?
Thanks in advance.
Check the html code that PrimeFaces is generating and use the css classes to define your styles, for your posted code something like this should work
.sso_header .ui-menuitem.ui-widget.ui-corner-all:last-child {
float: right;
}

How to correctly set p:autoComplete width to fill a panel

How can I set the autoComplete width to fill the panel correctly?
As you can see, using:
.ui-autocomplete input {
width: 100%;
}
will put the arrow out of the panel
EDIT: panelGrid
<p:panelGrid columns="3" style="border: hidden; width: 100%" styleClass="ui-panelgrid-blank">
<p:panelGrid>
<p:outputLabel value="Item name" for="haveName" />
<br/>
<p:autoComplete id="haveName" effect="fade" dropdown="true" forceSelection="true"/>
</p:panelGrid>
<p:panelGrid>
<p:outputLabel value="Paint" for="havePaint" />
<br/>
<p:autoComplete id="havePaint" effect="fade" dropdown="true" forceSelection="true"/>
</p:panelGrid>
<p:panelGrid>
<p:outputLabel value="Certification" for="haveCert" />
<br/>
<p:autoComplete id="haveCert" effect="fade" dropdown="true" forceSelection="true"/>
</p:panelGrid>
</p:panelGrid>
EDIT2: this is what happens when I set style="width: 100%" in the autoComplete tag:
EDIT3: this happens when I combine both:
If someone else is wondering how to achieve a full responsive autocomplete component on:
PrimeNg version: 4.0.3
Angular: 4.0.3
For me the only possible thing on earth that worked was a combination of this styles :
[style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" class="p-autocomplete"
with the following definition of the css:
.p-autocomplete{
width: 100%;
}
Hooope this helps!
In version primeng 11.3.2, you have to combine [style] and [inputStyle]:
[style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}"
If you use the attribute [multiple] =" true ", wrap the <p-autoComplete> </p-autoComplete> in a span with the class p-fluid
<span class="p-fluid">
<p-autoComplete class="mdb-autocomplete" field="email" placeholder="Search user"
[(ngModel)]="item_ac" [suggestions]="filterAC"[multiple]="true"
[style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}"
(completeMethod)="onCompleteAC($event)"
(onSelect)="onSelectAC($event)" (onUnselect)="onUnselectAC($event)">
<ng-template let-item_ac pTemplate="item">
<div class="div-item-ac">
</div>
</ng-template>
</p-autoComplete>
</span>
It Worked for me this way
.ui-autocomplete{
width: 100% !important;}
.ui-autocomplete-input{
width: 90% !important;}
Use the !important css declaration.
PrimeNG ULTIMA 5.2.0, PrimeNG 5.2.0
Setting the style width for .md-autocomplete when your <p-autoComplete> element is children of an ui-inputgroup
will cause the width being overwritten by the definition body .ui-inputgroup *[class^="md-"].
Take a look how the width in .md-autocomplete gets overwritten (at bottom):
You should make you definition !important Take a look how the width in .md-autocomplete gets not overwritten (at bottom):
And additionally the style attribute of the element p-autoComplete should look like:
[style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}".
In PF 6.1 <p:autocomplete> has a size attribute for this, setting it to "100%" works for me.
Using the version 13, you can use the fluid class on your span tag like this
<span class="p-fluid"> <p-autoComplete [(ngModel)]="selectedCountries" [suggestions]="filteredCountries" (completeMethod)="filterCountry($event)" field="name" [multiple]="true"> </p-autoComplete> </span>
then your autocomplete will take the 100% of width

Primefaces tab header style

Could someone help me hide tab headers with css?
I'm using primefaces controls and there is one general tabview on page. And there's one tabview(ribbon) on each tab of general tabview.
I need hide all tabs headers of child tabview, but show tabs headers of general tabview.
I've try to make it by using
.ui-tabs.ui-tabs-top > .ui-tabs-nav {
display: none!important;
}
But this code hides all headers.
My code:
<ui:composition template="./../WEB-INF/pagesTemplate.xhtml">
<ui:define name="content">
<h:form id="centralTable">
<p:tabView id="tabview"
value="#{tabView.tabList}"
widgetVar="wtabview"
style="height: 100%"
dynamic="true">
<p:ajax event="tabChange" listener="#{tabView.onTabChange}"/>
<c:forEach items="#{tabView.tabList}" var="pageUrl">
<p:tab title= "#{msg[tabView.getCommonTitleByPage(pageUrl)]}">
<ui:include src="#{pageUrl}" />
</p:tab>
</c:forEach>
</p:tabView>
</h:form>
</ui:define>
</ui:composition>
Example tab of general tabview:
<p:tab title="#{msg['header.Main.Model']}">
<p:ribbon id="ribbonPannelModel">
<p:tab title="Model" id="tabModel" >
<p:ribbonGroup label="#{msg['header.Common.Editing']}" id="rgModelEdit">
...
</p:ribbonGroup>
</p:tab>
</p:ribbon>
<p:dataTable id="dtModel" widgetVar="wdtModel">
...
</p:dataTable>
</p:tab>
And I need to hide <p:tab title="Model" id="tabModel" > - this header
You must use an id for the tabs that you aim and then apply the style to it
#myTabId .ui-tabs.ui-tabs-top > .ui-tabs-nav {
display: none!important;
}
I am not sure about the space between the #myTabId and .ui-tabs try to use and delete it and see the result
Just add the styleClass "hideTabHeader" to p:tabView styleClass.
<p:tabView id="idXYZTabView" styleClass="hideTabHeader" ..
And the following to your CSS file:
.hideTabHeader > .ui-tabs-nav
{
display: none !important;
}
Easy and reusable for other TabView's.

How to Override .ui-panelgrid td for specific <p:panelGrid>

How do I override a specific <p:panelGrid> in my Stylecheet?
In according to this: How to hide time-slots ...
I tried:
#frm_dash\3Adisplay td.ui-panelgrid {
padding:0px 0px;
}
and
#frm_dash\3Adisplay .ui-panelgrid td {
padding:0px 0px;
}
But it seems not working.
The page is build in this physical structure:
<h:form id="frm_dash">
[...]
<p:panelGrid id="pnlg_page" style="width: 100%;">
[...]
<p:row>
<p:column style="width: 50%; vertical-align: top" colspan="1">
<p:panelGrid id="display" columns="2">
[...]
</p:panelGrid>
</p:column>
<p:column colspan="1" style="vertical-align: top;">
[...]
</p:column>
</p:row>
[...]
</p:panelGrid>
[...]
</h:form>
Primefaces 3.4.1. - Tomcat 7.x - Mojarra
Thanks for your help.
You made 2 mistakes:
The \3A must be followed by a blank space.
The .ui-panelgrid class is been set on the <table> itself, not on a child of it.
So, this should do:
#frm_dash\3A display.ui-panelgrid td {
padding: 0;
}
Or just this, as it makes no sense to use a classname selector on an element which is already selected by an ID which is by itself supposed to be unique already:
#frm_dash\3A display td {
padding: 0;
}
As a different alternative, give the panel grid a style class so that you can reuse the same appearance on the other elements:
<p:panelGrid id="display" columns="2" styleClass="nopadding">
with (a more clean CSS selector)
table.nopadding td {
padding: 0;
}
See also:
How to use JSF generated HTML element ID with colon ":" in CSS selectors?
just add a css code
.ui-panelgrid .ui-panelgrid-cell{
padding 0px;
}
this code if you import your page kill primefaces css

Pass CSS property dynamically from panelgrid

I have a hidden property which is fetched from ebean. how do i pass that color code property to css function?
<h:panelGrid id="testpanel"
columns="#{message.no_of_columns}" rows="#{message.no_of_rows}"
styleClass="dynamicGrid">
<c:forEach items="#{bLDashBoardAction.listBondLoc}" var="item">
<h:panelGroup> <h:outputText value="#{item.rackTagCode}" />
<h:hiddenInput value="#{item.colorEBean.colorCode};" />
</h:panelGroup>
</c:forEach>
</h:panelGrid>
this is my css property,background need to be assigned from panelgrid colorcode
.dynamicGrid td
{
width: 50px;
height: 50px;
border: 4px solid gray;
background:
}
As you're restricted by strange design, your best bet is really to apply the style directly on the cell's content instead.
<h:outputText value="#{item.rackTagCode}" style="display:block;color:#{item.colorEBean.colorCode};" />
The display:block will make it to span the entire cell.
Don't think you can pass from JSF to css , you can create several classes with predefined background color , like .dynamicGridRed and .dynamicGridYellow
and call them conditionally styleClass="#{item.colorEBean.colorCode}"
wher colorCode can return dynamicGridRed or dynamicGridYellow
or something like
styleClass="#{item.colorEBean.useRedCode?'dynamicGridRed':'dynamicGridYellow'}"
another option would be use inline css like:
style="width: 50px;height: 50px;border: 4px solid gray;background:#{item.colorEBean.colorCode}"
INMO , you better not try to manipulate the content of css, just make a bunch of predefined css classes...
but I'm not a css pro , so i might be wrong

Resources