I have an extendedDataTable inside of a Panel (I also tried just sticking it in a div). The width of the table extends to fill the parent instead of the parent shrinking to the content.
code for the table
<h:body>
<ui:composition template="../main_template.xhtml">
<ui:define name="content">
<h:form>
<div class="table_panel">
<rich:extendedDataTable value="#{user_list.userList}" var="user" filterVar="filterValue" id="table"
sortPriority="#{userListSortingBean.sortPriorities}"
selectionMode="none"
rowClasses="odd_row, even_row">
<rich:column sortBy="#{user.nameFirst}" filterExpression="#{empty filterValue or fn:startsWith(user.nameFirst, filterValue)}">
<f:facet name="header">First Name</f:facet>
<h:outputText value="#{user.nameFirst}" />
</rich:column>
<rich:column sortBy="#{user.nameLast}" filterExpression="#{empty filterValue or fn:startsWith(user.nameLast, filterValue)}">
<f:facet name="header">Last Name</f:facet>
<h:outputText value="#{user.nameLast}" />
</rich:column>
<rich:column sortBy="#{user.email}" filterExpression="#{empty filterValue or fn:startsWith(user.email, filterValue)}">
<f:facet name="header">Email</f:facet>
<h:outputText value="#{user.email}" />
</rich:column>
<rich:column sortBy="#{user.company.name}" filterExpression="#{empty filterValue or fn:startsWith(user.company.name, filterValue)}">
<f:facet name="header">Company</f:facet>
<h:outputText value="#{user.company.name}" />
</rich:column>
<rich:column sortBy="#{user.company.activeFlag}" filterExpression="#{empty filterValue or fn:startsWith(user.company.activeFlag, filterValue)}">
<f:facet name="header">Company Active Status</f:facet>
<h:outputText value="#{user.company.activeFlag}" />
</rich:column>
<rich:column sortBy="#{user.company.expirationDate}" filterExpression="#{empty filterValue or fn:startsWith(user.company.expirationDate, filterValue)}">
<f:facet name="header">Expiration Date</f:facet>
<h:outputText value="#{user.company.expirationDate}" />
</rich:column>
</rich:extendedDataTable>
<rich:messages />
</div>
</h:form>
</ui:define>
</ui:composition>
relevant css
#main_content .table_panel {
background-color: #BED6F8;
color: #0066cc;
border-width: 3px;
}
#main_content .rf-edt {
border: none;
}
#main_content .rf-edt-ftr {
border: none;
}
.even_row {
background-color: #ECF3FE;
}
.odd_row {
background-color: #FCFFFE;
}
and I intended to post a picture of the result, but don't have the reputation for it. What is going on Is my wrapper div is being filled by the table even though the data in the table only needs about 50% of the space. I just need the table to shrink down to it's contents.
Just for information's sake. As of richfaces 4.3.3 this is just how the column widths work. We ended up making the table just a bit smaller than the sum of all the columns and accepting the bottom scroll bar.
Related
My problems is that when I click in the button to export data table, It exports only columns headers, my excel file is generated with none rows.
<h:form>
<p:dataTable id="cteTable" var="cte"
emptyMessage="Nenhum Registro Localizado"
reflow="true" value="#{extratorBean.ctes}" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
style="margin-top: 10px" paginator="true" rows="100" scrollable="true" scrollWidth="1024px">
<f:facet name="{Exporters}">
<h:commandLink>
<p:graphicImage name="images/excel.png" width="24" library="samsung" />
<p:dataExporter type="xls" target="cteTable" fileName="cte-s" />
</h:commandLink>
</f:facet>
<p:column headerText="CNPJ Emissor" width="150" style="text-align: center">
<h:outputText value="#{cte.EMIT_CNPJ}"/>
</p:column>
<p:column headerText="Serie" width="60" style="text-align: center">
<h:outputText value="#{cte.IDE_SERIE}"/>
</p:column>
<p:column headerText="N° CT-e" width="90" style="text-align: center">
<h:outputText value="#{cte.IDE_NCT}"/>
</p:column>
<p:column headerText="Dt. Emissão" width="150" style="text-align: center">
<h:outputText value="#{cte.IDE_DHEMI}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Total Frete" width="80" style="text-align: center">
<h:outputText value="#{cte.VPREST_VTPREST}">
<f:convertNumber type="currency" />
</h:outputText>
</p:column>
<p:column headerText="ICMS" width="80" style="text-align: center">
<h:outputText value="#{cte.ICMS_VICMS}">
<f:convertNumber type="currency" />
</h:outputText>
</p:column>
<p:column headerText="% ICMS" width="80" style="text-align: center">
<h:outputText value="#{cte.ICMS_PICMS}">
<f:convertNumber minFractionDigits="2" />
</h:outputText>
</p:column>
<p:column headerText="Nat. Op." width="350" style="text-align: center">
<h:outputText value="#{cte.IDE_NATOP}"/>
</p:column>
<p:column headerText="CNPJ Tomador" width="150" style="text-align: center">
<h:outputText value="#{cte.TOMADOR}"/>
</p:column>
<p:column headerText="Chave Acesso" width="350" style="text-align: center">
<h:outputText value="#{cte.TRANSACTIONID}"/>
</p:column>
<p:column headerText="Dt. Criação" width="120" style="text-align: center">
<h:outputText value="#{cte.IDE_TIMESTAMP}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="N° Protocolo" width="120" style="text-align: center">
<h:outputText value="#{cte.IDE_AUTHCODESEFAZ}"/>
</p:column>
</p:dataTable>
</h:form>
I'm using primefaces 5.3 and tried to use apache poi 3.8 and 3.10-FINAL but both did not work right.
In the log i've got no errors.
Edit: I already know what is happening.
The problem is that when my table is load, it's empty, but looks like the button to export It to excel, keeps some kind of cache with the table empty, and even after I load data into the table, the button keeps exporting the excel empty.
Now, I don't know how to solve this problem.
Well, if someone else get into this problem, here is the answer that corrects mine:
My managed bean was request scoped. But when I clicked the button to export excel, It makes a new request to the maneged bean. And in this request my list was null. I checked this by putting a breakpoint in the method getList.
So I simply change the scope of my managed bean from request scope to view scope and It works fine.
It seems that the exporter use the property for filtered data, so at the first time, you get only headers because the filtered data is empty. I suggest try adding data to the filtered data in the load of the page.
add f:facet header after your p:column
<p:column>
<f:facet name="header">
<h:outputText value="CNPJ Emissor"/>
</f:facet>
<h:outputText value="#{cte.EMIT_CNPJ}"/>
</p:column>
The data in the following picture is dynamic & that is not looking good actually.
I want to fix the width for these columns.
<p:row styleClass="ui-panelgrid-cell" rowspan="2">
<p:column>
<div style="overflow: auto; width: 100%;">
<p:dataTable var="tPreferences"
value="#{userPreferences.preferences}"
emptyMessage="No Questions Found." id="pTable" styleClass="borderless">
<p:column headerText="PREFERENCES">
<h:outputText id="sName" styleClass="cellLabelMand"
value="#{tPreferences.shortText}" />
<h:outputText value="<br/><br/>" escape="false" />
<h:selectManyCheckbox id="grid"
value="#{tPreferences.preferencesSelectedItem}"
layout="grid" columns="1">
<f:selectItems value="#{tPreferences.catList}" var="pref" />
</h:selectManyCheckbox>
</p:column>
</p:dataTable>
</div>
</p:column>
</p:row>
I am using Richfaces 4.1 with myFaces 2.1.5. I have a data table with command links. When i load the page and click the links I instatly get viewExpiredException, no matter how much I wait before clicking, so session cannot expire on the server. I save the viewstate on server. What else can cause the loss of the viewstate?
Here is my code:
<h:form class="page_frame">
<rich:dataTable value="#{RunArchiveBean.archivedRuns}" var="run" id="run_table"
style="width: 900px; margin-top: 50px; margin-left: auto; margin-right: auto"
rowClasses="odd-row, even-row" styleClass="even_odd">
<f:facet name="header">
<h:outputText class="output_text_header" value="Run History" />
</f:facet>
<rich:column styleClass="run_archive_column" >
<f:facet name="header">Name<br/></f:facet>
<h:outputText value="#{run.name}"></h:outputText>
</rich:column>
<rich:column styleClass="run_archive_column" >
<f:facet name="header">Network<br/></f:facet>
<h:outputText value="#{run.network}"></h:outputText>
</rich:column>
<rich:column styleClass="run_archive_column" >
<f:facet name="header">Network Element<br/></f:facet>
<h:outputText value="#{run.networkElement}"></h:outputText>
</rich:column>
<rich:column styleClass="run_archive_column">
<f:facet name="header">Creation Date<br/></f:facet>
<h:outputText value="#{run.creationDate}"></h:outputText>
</rich:column>
<rich:column styleClass="run_archive_column">
<f:facet name="header">Run Date<br/></f:facet>
<h:outputText value="#{run.timestamp}"></h:outputText>
</rich:column>
<rich:column styleClass="run_archive_column_results" >
<f:facet name="header">Actions<br/></f:facet>
<a4j:commandLink execute="#this" action="alert('OK');" >
<h:graphicImage id="log_image" name="log.png" library="images" style="border:0" />
<rich:tooltip followMouse="true" target="log_image" value="Log" />
</a4j:commandLink>
</rich:column>
</rich:dataTable>
</h:form>
Looks like the server-side saving is the issue, though I can't say why - I've never encountered this error in newer versions of RichFaces. Switching to client-side saving should solve it.
For a more detailed explanation see this question.
Hi I am attaching my code, My problem i si am getting a list from the database and i am dispalying on the UI in a datatable with only checkbox.
Once user will select any of the check box then i need to renderedd on text area for that checkbox. So checkbox and textarea will be dynamic.
I have written some code in bean also but that is not working for first object it is working fine but for remaining object it is not workinhg please help to resolve problem
Bean Code:
public void addSharedMessage()
{
for(DocumentTypeDTO documentTypeDTO1 : shareGovtAgencyList)
{
System.out.println(documentTypeDTO1.getSelected());
if( documentTypeDTO1.getSelected())
{
this.setSharedMessageRendered(true);
setSharedMessageRendered(true);
} else {
this.setSharedMessageRendered(false);
}
}
}
XHTML code:
<rich:dataTable width="100%" id="searchResult" border="0" rowKeyVar="
value="#{myBean.sharedList}" var="item"
headerClass="head" cellpadding="2"
rowClasses="odd,even" cellspacing="0" bgcolor="#FFFFFF">
<rich:column style="text-align:center; background-color:#FFFFFF" width="1%">
<h:selectBooleanCheckbox id="khudh" value="#{item.selected}" immediate="true" >
<a4j:support event="onchange" action="#{myeBean.addSharedMessage}" reRender="committeemenbersname" />
</h:selectBooleanCheckbox>
</rich:column>
<rich:column style="background-color:#FFFFFF" id="committeemenbersname" >
<h:outputText value="#{item.documentName}" />
<rich:separator lineType="none" />
<h:inputTextarea id="shareProfileComment" rows="2" cols="45"
rendered="#{myBean.isSharedMessageRendered}" >
<f:validateLength maximum="200" />
</h:inputTextarea>
</rich:column>
</rich:dataTable>
Don't iterate all the values every time. you did any one value is true, and all the remaining should be false. I think this is the problem.
Try this,
public String addSharedMessageAction()
{
DocumentTypeDTO documentTypeDTO1 = shareGovtAgencyList.get(dataTableIndex);
System.out.println(documentTypeDTO1.getSelected());
if (documentTypeDTO1.isSelected())
{
documentTypeDTO1.setSharedMessageRendered(true);
}
else
{
documentTypeDTO1.setSharedMessageRendered(false);
}
return null;
}
XHTML code:
<rich:dataTable id="dataTableID"
value="#{Sample.sampleList}"
rendered="#{Sample.sampleDataTableRendered}"
var="sampleBean"
width="600"
rowKeyVar="currentIndex">
<f:facet name="header">
<rich:columnGroup>
<rich:column>
<h:outputText value="select"/>
</rich:column>
<rich:column>
<h:outputText value="Comment"/>
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column >
<h:selectBooleanCheckbox id="checkboxId"
value="#{sampleBean.selected}">
<a4j:support action="#{Sample.addSharedMessageAction}"
event="onclick" reRender="dataTableID">
<a4j:actionparam name="actionParemId"
value="#{currentIndex}"
assignTo="#{Sample.dataTableIndex}"/>
</a4j:support>
</h:selectBooleanCheckbox>
</rich:column>
<rich:column >
<h:inputTextarea value="#{sampleBean.comment}"
rendered="#{sampleBean.isSharedMessageRendered}"/>
</rich:column>
</rich:dataTable>
How can I align a graphicImage which will come as an element as a column in the middle .Now It is left aligned. I tried a lot but it will not work.
<p:column>
<f:facet name="header">
<h:outputText value="Status" />
</f:facet>
<h:graphicImage value="../resources/images/Yellow_button.png"
style="float:center;height: 18px; width: 20px"
rendered="#{categorey.status == 1}" title="READY TO ZIP"/>
<p:column>
You can align the table cell content for the whole column:
<p:column style="text-align: center">
<f:facet name="header">
<h:outputText value="Status" />
</f:facet>
<h:graphicImage value="../resources/images/Yellow_button.png" />
</p:column>
In order to separate the layout you can use the styleClass attribute referencing a class from a css resource as well.