p:dataList rendering in Internet Explorer 8 - jsf

my page contains a data list within another data list. The outer data list simulates an accordion panel, while the inner data list renders my dynamic columns.
Everything works fine, but Internet Explorer 8 behaves differently in respect of Firefox and Chrome, because in the resulting html it renders some empty objects that leaves a blank space before data.
The screenshots show the differences between Explorer 8 and Firefox.
Firefox generated HTML:
Explorer 8 generated HTML:
Firefox rendering:
Explorer 8 rendering:
Here is the code:
<p:dataList id="data" styleClass="myDataList" value="#{bean.getAnag(idSito)}" var="tipologia" itemType="disc" type="definition">
<div class="ui-accordion ui-widget ui-helper-reset ui-hidden-container tabAccordion" style="width: 100%;">
<table id="accordionFake#{idSito}" border="1" class="table-din-col" style="display: none; margin-bottom: 10px;">
<!-- HEADERS -->
<tr class="table-din-col-titolo">
<td style="padding: 4px;">
<h:outputText value="Codice" />
</td>
<td style="padding: 4px;">
<h:outputText value="Descrizione" />
</td>
<td style="padding: 4px;">
<h:outputText value="CodiceAgg" />
</td>
<td style="padding: 4px;">
<h:outputText value="Pos" />
</td>
<p:dataList value="#{bean.buildColumns(idSito)}" var="colDin" type="definition">
<td>
<h:outputText value="#{colDin.header}" />
</td>
</p:dataList>
</tr>
<!-- HEADERS -->
<!-- ROWS BUILDING -->
<p:dataList id="dataL" var="rilevazione" selectionMode="single"
value="#{bean.getLsLoc(idSito)}" type="definition">
<tr class="table-din-col-righe">
<td class="table-din-col-colonne">
<h:outputText id="codice" value="#{rilevazione.codice}" />
</td>
<td class="table-din-col-colonne">
<h:outputText id="desc" value="#{rilevazione.descrizione}" />
</td>
<td class="table-din-col-colonne">
<h:outputText id="codSnam" value="#{rilevazione.codiceAgg}" />
</td>
<td class="table-din-col-colonne">
<h:outputText id="pos" value="#{rilevazione.pos}" />
</td>
<p:dataList value="#{bean.buildColumns(idSito)}" var="colDin" type="definition">
<td class="table-din-col-colonne">
<h:outputText value="#{colDin.property.valore}" />
</td>
</p:dataList>
</tr>
</p:dataList>
<!-- ROWS BUILDING -->
</table>
</div
</p:dataList>
How can I instruct ie8 to correctly render the data lists?
Thanks in advance.

It look like you was using the wrong component for the purpose, or are at least not understanding/familiar with basic HTML.
The <p:dataList> gives you the option to generate a HTML <ul><li> (unordered list), <ol><li> (ordered list) or <dl><dt><dd> (definition list).
However, you seem to be after generating a plain vanilla HTML <table><tr><td> with all cells hardcoded. You have nested a <p:dataList type="definition"> inside <tr> which would only generate <dl><dt><dd> elements inplace where <td> elements are expected. This only ends up in illegal HTML syntax. IE is rather sensitive to that.
You should replace the nested <p:dataList type="definition"> components by <ui:repeat>. It doesn't generate any HTML and your HTML will end up syntactically valid (although I wonder how it makes sense to have a <dl><dt><dd><table>, after all, I suggest to learn basic HTML as well, so that you can better understand which JSF components to pick for the purpose).

Related

How to achieve complex header in Bootsfaces datatable

I am using Bootsfaces datatable to display my data. However, I want to achieve complex header as shown here: https://datatables.net/examples/basic_init/complex_header.html
I tried to add <th rowspan> and <th colspan> directly under header facet in the first dataTableColumn, but that have a ugly empty row at the top.
I also tried to add the whole header facet under <b:dataTable...> tag, before the fist <b:dataTableColumn>, but that header code won't be generated into the html. Any other suggestions? I do not want to switch to primefaces or richfaces as my framework as been fixed.
My code that trying to achieve the complex header looks like below:
<b:dataTable value="#{podStatusListBean.podStatusBeanList}"
var="podStatus"
id="podStatuses">
<b:dataTableColumn footer-style='background-color:orange'
footer-styleclass="{podStatusListBean.footerVisibility}">
<f:facet name="header">
<tr>
<th rowspan="2">Name</th>
<th colspan="2">HR Information</th>
<th colspan="3">Contact</th>
</tr>
</f:facet>
...
This is a new feature we've added to the next BootsFaces version (probably 1.2). As of June 15, 2017, the current version of BootsFaces 1.1.1 only supports complex headers on a per-column basis.
Complex headers per column (supported since BootsFaces 0.8.0):
Add a header facets to the <b:dataTableColumn />, pretty much the way you tried. But keep in mind that BootsFaces already generates the <tr> and <th> tags, so you can nest them a second time. But you can do something like this:
<b:dataTableColumn>
<f:facet name="header">
<ul
style="margin-bottom: 0; list-style-type: none; padding-left: 0">
<li>Price</li>
<li>Engine Power</li>
</ul>
</f:facet>
€ #{car.price}
<br />
#{car.enginePowerKW} KW (#{car.enginePower} hp)
</b:dataTableColumn>
</b:dataTable>
More complex headers (will be supported beginning with BootsFaces 1.2.0):
Add a header facet to the surrounding <b:dataTable /> tag. In this case you're responsible for defining the correct number of table headers. If you skip one, you'll be rewarded by a JavaScript error. In many cases it will even go by unnoticed, but the initialization of the datatable is incomplete, so you'd rather be careful.
<b:dataTable value="#{carPool.carPool}"
var="car"
page-length="5"
page-length-menu="5,10,20">
<f:facet name="header">
<tr>
<th rowspan="2">Car</th>
<th colspan="2">Appearance</th>
<th colspan="2">Technical Data</th>
</tr>
<tr>
<th>Color</th>
<th>Year</th>
<th>Price</th>
<th>Power</th>
</tr>
</f:facet>
<b:dataTableColumn>
#{car.brand} #{car.type}
</b:dataTableColumn>
<b:dataTableColumn value="#{car.color}" />
<b:dataTableColumn value="#{car.year}" order="asc" />
<b:dataTableColumn value="#{car.price}" />
<b:dataTableColumn value="#{car.enginePower}"/>
</b:dataTable>

Primefaces - How to show and hide two different `panel` components in one location

I need your help in showing and hiding two different panel components in one location. Currently in the page at the top, I am allowing the user to select one choice from the selectOneRadio component.
Below the selectOneRadio component, I am placing two different panel components where I am using the rendered attribute to show or hide the panel based on the selection. For example if the user selects the first option, the first panel will be shown and the second will be hidden and if he chose the second option, the first panel component will be hidden and the second will be shown.
However, the issue which I am facing is if the user selects the second option that the first panel will be hidden and there will be a huge space as I am placing panelGrid components and inputText components under the first panel and below it, the second panel will be shown. So how can I make the second panel to be shown in the location of the first panel.
Here is the JSF code:
<table border="0" cellspacing="0" width="100%">
<tr>
<td>
<p:outputLabel value="Please Select a Request Type:"/>
</td>
</tr>
<tr>
<p:selectOneRadio id="request" layout="pageDirection" value="#{user.requestType}">
<td width="50%">
<f:selectItem itemLabel="Certificates for Other" itemValue="O"/>
</td>
<td width="50%">
<f:selectItem itemLabel="Certificates for Banks" itemValue="B"/>
</td>
<p:ajax event="change" update="#form" listener="#{user.firstToggle}"/>
</p:selectOneRadio>
</tr>
</table>
<p:panel id="toggleable" header="Certificates for Other" toggleable="true" rendered="#{user.firstTogg}" widgetVar="panel" style="margin-bottom:20px">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td height="100%">
<p:selectOneMenu label="c_e_language_hr" id="c_e_language_hr" disabled="#{user.firstTogg}" value="#{user.employmentCertificateLanguageHr}">
<f:selectItem itemLabel="Please Select a Language" itemValue="F"/>
<f:selectItems value="#{user.ceLangDesc}" var="celang" itemLabel="#{celang.langDesc}" itemValue="#{celang.langCd}"/>
</p:selectOneMenu>
</td>
</tr>
</table>
</p:panel>
<p:panel id="toggleable1" header="Certificates for Banks" toggleable="true" rendered="#{user.secondToggle}" widgetVar="panel1" style="margin-bottom:15px">
</p:panel>

Primefaces selectOne Radio button not working as required

I have a condition where i need to have two radio buttond with related data in the below the buttons.
i did something like below but the selected radio button value is not getting in the backed been. Please correct where i am going wrong
<table>
<tr>
<td>
<h:selectOneRadio value="#{beenObject.adressSelection}">
<f:selectItem itemValue="Employer" itemLabel="Employer" />
</h:selectOneRadio>.
</td>
<td>
<h:selectOneRadio value="#{beenObject.adressSelection}">
<f:selectItem itemValue="Consultant" itemLabel="Consultant" />
</h:selectOneRadio>.
</td>
</tr>
<tr>
<td>
<h:outputText value="#{beenObject.consultentDetailsString}">
</h:outputText>
</td>
</tr>
<tr>
<td>
<h:outputText value="#{beenObject.employerDetailsString}">
</h:outputText>
</td>
</tr>
</table>
I'm facing an issue similar as yours however I tried to replicate my situation at your code. While I was simplifying the lines I just end-up fixing your bug.
Below the code wich will work for you.
<table>
<tr>
<td>
<h:selectOneRadio value="#{beenObject.adressSelection}">
<f:selectItem itemValue="Employer" itemLabel="Employer" />
<f:selectItem itemValue="Consultant" itemLabel="Consultant" />
</h:selectOneRadio>
</td>
</tr>
<tr>
<td>
<h:outputText value="#{beenObject.consultentDetailsString}">
</h:outputText>
<h:outputText value="#{beenObject.employerDetailsString}">
</h:outputText>
</td>
</tr>
</table>
Explaining what I did:
I grouped the elements f:selectItem underneath f:selectItems like is shown in the sample at primeface showcase and it starts to work.
Hope it work as you want.
Cheers.

Mix of HTML table and PrimeFaces p:datatable

When I try to put in plain HTML table in a PrimeFaces <p:dataTable> the output of the resulting table becomes weird and overlapped.
The code I tried is:
<table border="0" cellpadding="0" cellspacing="0" width="509" style="border-collapse: collapse;width:382pt">
<tbody>
<tr height="19" style="height:14.4pt">
<p:dataTable>
<p:column>
<table>
<tr><td>abc</td></tr>
</table>
</p:column>
</p:datatable>
</tr>
</tbody>
</table>

How to change font size in JSF page

I have this simple JSF table which is use to display data from Database and also to edit data.
<table>
<ui:repeat var="ud" value="#{DCProfileTabGeneralController.dcData}">
<tr>
<td>Datacenter Type</td>
<td>
<h:outputText value="#{ud.type}"
rendered="#{not DCProfileTabGeneralController.editable}" />
<h:inputText value="#{ud.type}" rendered="#{DCProfileTabGeneralController.editable}" />
</td>
</tr>
<tr>
<td>Date Added</td>
<td>
<h:outputText value="#{ud.dateAdded}"
rendered="#{not DCProfileTabGeneralController.editable}" />
<h:inputText styleClass="datepicker" value="#{ud.dateAdded}" rendered="#{DCProfileTabGeneralController.editable}" />
</td>
</tr>
<tr>
<td>Hour Added</td>
<td>
<h:outputText value="#{ud.hourAdded}"
rendered="#{not DCProfileTabGeneralController.editable}" />
<h:inputText value="#{ud.hourAdded}" rendered="#{DCProfileTabGeneralController.editable}" />
</td>
</tr>
<tr>
<td>Date Deployed</td>
<td>
<h:outputText value="#{ud.dateDeployed}"
rendered="#{not DCProfileTabGeneralController.editable}" />
<h:inputText styleClass="datepicker" value="#{ud.dateDeployed}" rendered="#{DCProfileTabGeneralController.editable}" />
</td>
</tr>
<tr>
<td>Hour Deployed</td>
<td>
<h:outputText value="#{ud.hourDeployed}"
rendered="#{not DCProfileTabGeneralController.editable}" />
<h:inputText value="#{ud.hourDeployed}" rendered="#{DCProfileTabGeneralController.editable}" />
</td>
</tr>
</ui:repeat>
</table>
Now I want to extend the table in this way. When the Boolean flag is true I want to display the text in 12px. When the Boolean flag is false I want to display the text in 20 px. Is this possible in JSF?
You can simply use an EL expression to set the appropriate CSS style:
<table id="idTable"
style="font-size: #{DCProfileTabGeneralController.editable ? '12px' : '20px' }">

Resources