I want to build a tree which has p:oanelGrid as nodes. Like this:
<o:tree value="#{plannedElementsBean.tree}" var="item">
<o:treeNode level="0">
<o:treeNodeItem>
<p:panelGrid columns="6">
<f:facet name="header">
<h:outputText value="Header" />
</f:facet>
<o:treeInsertChildren />
<p:panel><h:outputText value="Inner" /></p:panel>
<f:facet name="footer">
<h:outputText value="Footer" />
</f:facet>
</p:panelGrid>
</o:treeNodeItem>
</o:treeNode>
</o:tree>
The problem is, that the vertical lines between the children are missing. p:panelGrid renders vertical lines between its children. And I tested it, with static markup. But all the children inserted by the o:tree are treated as if they where the first child, and thus rendered into the first part, while the inner panel is rendered into a second part, divided by a vertical line. I would like to have all inserted children and the inner panel be divided by a vertical line. What is going wrong here?
This is indeed expected behavior. The <o:tree> and friends are UI components like <ui:repeat> and not tag handlers like <c:forEach>. The <p:panelGrid> renders a <td> per UI component child.
You seem to think that <o:tree> (and equivalently <ui:repeat>) recursively generates multiple JSF components which end up in place of <o:treeInsertChildren>. This is not true. There's really physically only one JSF component in the component tree which repeatedly generates its HTML output depending on the current iteration state. There's physically only one <o:treeInsertChildren> component whose all the HTML output ends up in a single <td> of <p:panelGrid>.
Your best bet is just using left-floating divs with a fixed width of 16% so that they break to next line after each 6 items. Note that you can easily reuse PrimeFaces standard CSS classes on plain HTML elements, if necessary.
See also:
c:forEach inside primefaces(e.g. p:panelgrid) inside ui:repeat
ui:repeat JSF 2.0 cannot render iterate p:row primefaces
create table columns dynamically in JSF
Related
I am using p:spacer in my xhtml file to create some empty space in the left side of the Panel Grid, and right side I have two buttons. The alignment works fine for the resolution (1366 X 768 screens). But if the page is opened on a screen with a resolution 1280 X 1024 using IE 10 browser, the left side space increases and the right side buttons goes out of the view and a horizontal scroll bar appears. I don't want users to scroll to see the buttons. Sample code is given below.
<p:accordionPanel value="#{dataBean.userList}" var="j" activeIndex="null">
<p:tab title="#{j.department} - #{j.userCount}">
<p:panelGrid columns="2">
<p:column>
<p:spacer width="1050" height="5" />
</p:column>
<p:column>
How to put the space that will adjust based on the resolution ?
Using PrimeFaces 4.0.
I wouldn't recommend using p:spacer for that particular case. Instead, you can play with styles to achieve what you want to do. This will work:
Use this style (put it wherever you have your css):
<style type="text/css">
.grid{width: 100%;}
.column1{width: 100%;}
.column2{}
</style>
And use it in the styleClass and columnClasses attributes of the p:panelGrid like this:
<p:accordionPanel value="#{dataBean.userList}" var="j" activeIndex="null">
<p:tab title="#{j.department} - #{j.userCount}">
<p:panelGrid columns="2" styleClass="grid" columnClasses="column1,column2">
<p:column></p:column>
<p:column>
<p:commandButton value="hi"/>
<p:commandButton value="bye"/>
</p:column>
</p:panelGrid>
</p:tab>
</p:accordionPanel>
This way your first column will take all the available space leaving your second column with the buttons aligned to the right, and not depending on the resolution.
Is there any possibility rendering just certain items (based on their value) of radio buttons in jsf
e.g this below: (but this approach doesn't work)
<h:selectOneRadio value="#{user.favColor3}">
<f:selectItems rendered="c.colorValue eq 'red'" .... var="c"
</h:selectOneRadio>
So, I want to iterate over the items, and showing only the red item.
Thanks in advance.
Cs
I am using <p:autoComplete> in my webproject. When lots of data coming to the search box the position of list is from bottom to top instead of top to bottom and not all data is visible.
How can I fix it so that it shows the data from top to bottom?
You can use the scrollHeight attribute to define height of the items those are seen in list as follows
<p:autoComplete value="#{bean.text}" completeMethod="#{bean.complete}" scrollHeight = "150" />
Primefaces documentation will definitely help you regarding this
<p:autoComplete id="acOrden" value="#{serviciosMB.ordenSelect}"
completeMethod="#{serviciosMB.complete}"
var="mauto"
itemValue="#{mauto}"
itemLabel="#{mauto.consecutivoOrden}"
converter="ordenProduccionServiciolConverter" required="true">
<p:ajax event="itemSelect" listener="#{serviciosMB.renderPanelOrden}" update="panelOrden :form2:growl" />
<p:column>
#{mauto.codigoOrden}
</p:column>
</p:autoComplete>
see ajax listener
Suppose I have a left hand side panel and I want to change the forms in another panel based on the event of components on left panel.
How can I do it in JSF?
I searched a little bit and found that tabView in primefaces can do something like this.
But I would like to know whether there is another way of changing contents of another panel
from some event of one panel.
I understand that this question is not quite specific but I searched on google and couldn't find satisfactory answer so asking here.
Thanks for the help :)
1. You have some context in center:
Left:
<p:commandButton update="pncenter" actionListener="#{bean.update}"/>
Center:
<p:outputPanel id="pncenter">
<p:outputPanel id="pn1" rendered="#{bean.render eq '1'}">
// content here
</p:outputPanel>
<p:outputPanel id="pn2" rendered="#{bean.render eq '2'}">
// content here
</p:outputPanel>
///....
</p:outputPanel>
2. You have dynamic center:(Each center context is stored in a xhtml file)
Left:
<p:commandButton update="pncenter" actionListener="#{bean.update}"/>
Center:
<p:outputPanel id="pncenter">
<ui:include src="#{centerBean.link}"/>
</p:outputPanel>
bean.update method
centerBean.link = "/module/test1.xhtml"; // /module/test2.xhtml /module/test3.xhtml
I am new to primefaces and jsf and facing a few problems using it.
Following is the code i am using in jsf
<p:dataTable id="plazaId" var="plaza" value="#{coverageBean.plazaDataModel}" selection="#{coverageBean.selectedPlaza}" rowIndexVar="rowIndex" width="100%" border="0" cellspacing="0" cellpadding="0" >
<p:column id="name" headerText="Select" selectionMode="multiple"
style="width:18px" />
<p:column id="plazaName" headerText="Plaza's" style="width: 50%" bgcolor="#dcdcdc">
<h:outputText value="#{plaza.name}" bgcolor="#dcdcdc"></h:outputText>
</p:column>
<p:column id="plazaDirect" headerText="Directo" style="width: 10%" bgcolor="#dcdcdc">
<h:outputText value="#{plaza.direct}" bgcolor="#dcdcdc"></h:outputText>
</p:column>
</p:dataTable>
I have checked the Beans and backend. They are all correct.
The issues are :
I like to change the width using percentage in this table . But its not working.
I like all the rows to be of the same color. But its showing alternate colors (white and blue)
And is there a way to make the checkbox of simple html style . But its a little fancy.
Could anyone help with any of there problems. Thanks in advance
I like to change the width using percentage in this table . But its not working.
You have syntax issues with your JSF view. Their is no bgcolor attribute of h:outputText, this is a style attribute.
<h:outputText value="#{plaza.name}" headerText="Plazas" style="bgcolor: #dcdcdc;" />
This is also true for the p:column component as well...
<p:column id="plazaName" headerText="Plaza's" style="width: 50%; bgcolor: #dcdcdc;">
This also should fix your background color issue.
And is there a way to make the checkbox of simple html style . But its a little fancy.
This would actually be quite difficult to do. The p:selectBooleanCheckbox is really a styled div with javascript events attached to it. Within this div is a hidden input type="checkbox" that exists as the form element that gets posted back. You can't do this without tinkering with javascript and stylesheets that I know of.
As of today, this is not possible. Refer to http://code.google.com/p/primefaces/issues/detail?id=2801
It is to do with styling. Define style as required.
It is to do with styling. Define style as required.