JSF2 Primefaces datatable subtable or ui:repeat table - jsf

My data structure is like this:
ObjectA contains Strings varA, varB and a List of 24 ObjectBs.
ObjectB contains Strings varC,varD,varE.
I now have a List of ObjectAs.
I am trying to use a Primefaces datatable to get an output like this (in a table). (for each ObjectA)
How do I achieve this? In the screenshot below, the first column is the row index, the second column is the varA from ObjectA, third column is varB from ObjectA. Columns with headers 1 to 24 are the values of ONLY varC from each of the 24 ObjectBs. In the second row, columns with headers 1 to 24 are the values of ONLY varD from each of the 24 ObjectBs. In the third row, columns with headers 1 to 24 are the values of ONLY varE from each of the 24 ObjectBs.
After three rows are complete, now I take the next objectA2 and repeat the process. I was able to do this in a jsp using c:forEach tags. However, I am unable to get this done using JSF.
I even tried during normal HTML table using ui:repeat but if there are two ObjectB ui:repeats inside the ObjectA ui:repeat, only one of the ui:repeats is working and the other one is showing blank values.
<ui:repeat var="upto" value="#{getClearedTransactionsBean.clearedList}" varStatus="rowCounter">
<tr>
<td rowspan="3">#{rowCounter.index+1}</td>
<td><h:outputText value="#{upto.sink}"/></td>
<td>Cleared MW</td>
<ui:repeat value="#{upto.hourlyClearedList}" var="hourly">
<td><h:outputText value="#{hourly.clearedMW}"/></td>
</ui:repeat>
</tr>
<tr>
<td><h:outputText value="#{upto.sourceLocationLabel}"/></td>
<td>Source LMP</td>
<ui:repeat items="#{upto.hourlyClearedList}" var="hourly">
<td><h:outputText value="#{hourly.sourceLMP}"/></td>
</ui:repeat>
</tr>
<tr>
<td></td>
<td>Sink LMP</td>
<ui:repeat items="#{upto.hourlyClearedList}" var="hourly">
<td><h:outputText value="#{hourly.sinkLMP}"/></td>
</ui:repeat>
</tr>
<tr class="blankrow">
<td colspan="27"></td>
</tr>
</ui:repeat>
</table>
The above screenshot is the one that I did successfully in a jsp. But, I need to do this in JSF 2. Thanks !

Try to use dynamic columns. Prepare model for rows, may be object with columns data in HashMap.
http://www.primefaces.org/showcase/ui/data/datatable/columns.xhtml

Related

Netsuite / Freemarker - splitting item description by line is not working

Anyone who can help why the below code is not working.
This is my code:
<#list item.description?split("\n", 'r') as desc>
<tr>
<td align="left" colspan="23">${desc}</td>
</tr>
</#list>
I am editing an advance PDF/HTML template in Netsuite. I need to split the item description as 1 line per row. I wanted to split them like this because we have a case like for 1 item, there is a super long description and what happens is, instead of printing the items 1,2,3 in continuous flow, the print only displays 1 item in page 1 and the next item is in page 2 even though item 1 only occupied 10% of page 1. for item 2 (with very long description, it did occupy 100% of page 2).
If the code above is working correctly, then item 1 and item 2 should be printed on page 1 and some of the descriptions of item 2 should be on page 2.
I tried changing the code to <#list item.description?split(".") as desc> and it worked.
I found what works. Instead of "\n" or "\n", I use the br tag to split the item.descripiton.
<#list description?split("<br /><br />") as desc>

Removing the strings between two characters in excel

I have a large excel data sheet with thousands of rows and its filled with html codes with less than and greater than tags containing codes and other real information is outside of tags. Like;
Cables Supported </TD> <td class="specDetail fs18" data-selenium="specDetail"> RG-6 coax </TD> </TR> <tr> <td class="specTopic fs18" data-selenium="specTopic"> Weight Supported </TD> <td class="specDetail fs18" data-selenium="specDetail"> 80 lb (36 kg) </TD> </TR> </TBODY> </TABLE> <table class="specTable" data-selenium="specTable"> <tbody data-selenium="specBody"> <tr> <th class="specHeader Header" colspan="2" data-selenium="specHeader"> <a name="shipping" class="fs32 OpenSans-300-normal" id="shipping" data-selenium="specHeaderLink">Packaging Info</A> </TH> </TR> <tr> <td class="specTopic fs18" data-selenium="specTopic"> Package Weight </TD> <td class="specDetail fs18" data-selenium="specDetail"> 0.05 lb </TD> </TR> <tr> <td class="specTopic fs18" data-selenium="specTopic"> Box Dimensions (LxWxH) </TD> <td class="specDetail fs18" data-selenium="specDetail"> 3.3 x 2.0 x 0.2" </TD> </TR> </TBODY> </TABLE> </DIV> </DIV> <div class="rightPanel"> <div class="video-container"> <div class="content" data-selenium="content"> <script src="//players.brightcove.net/1661991858001/N1cfLQmFe_default/index.min.js" type="text/javascript"></SCRIPT> </DIV><!-- end content --> </DIV> </DIV> </DIV>
I need to remove everything inside "<" ">" including the less than and greater than characters. So at the end, result should look like this:
Cables Supported RG-6 coax Weight Supported 80 lb (36 kg) Package Weight 0.05 lb
Box Dimensions (LxWxH) 3.3 x 2.0 x 0.2"
Data to columns won't with that large data. It just doesn't fit. I'm stuck.
i cant write the formula properly freehand and dont currently have access to excel so this may need some name function name changing and possibly attribute order changing but it would look something like
=replace(a1, left(right(a1, find(a1,"<")),find(a1,">")),"")
which should do the following in pseudo code
s = string
m = position of first >
n = position of first <
o = the text to the left of the m'th letter of s
p = the text to the right of the n'th letter of o
replace p from s with ""
then copy the column with the formula in and past special (values) into the original string column until there are no more < or > (or record a macro to do that then either spam the key or edit it and surround the macro with a loop.

How to style a row in rich:datatable acording to the row value or index?

I have a rich:datatable like so:
<rich:dataTable var="scheduledTimeItem"
value="#{itineraryBean.weekDaysScheduledTimes}">
<rich:column style="text-align: center;">
<h:outputText>#{scheduledTimeItem.formattedStartTime} </h:outputText>
</rich:column>
</rich:datatable>
And I would like to, for example, put background-color: red in the style of that row if the value of scheduledTimeItem.formattedStartTime is greater than 17:00h or the current time for example.
How do I send the value of the row or its index to the bean at the time that is rendered?
You could do something like this
<h:outputText styleClass="#{scheduledTimeItem.style}">#{scheduledTimeItem.formattedStartTime} </h:outputText>
for every column.

How can I make a column in a sharepoint report hidden unless the field is populated?

I have a report in Sharepoint that I want to show the "End Date" field only if there is an end date. I'm using Knockout
<td class="ms-vb">
<b>End Date:</b>
</td>
<td class="ms-vb">
<span data-bind="text: EndDate"></span>
</td>
I just want this part of the report to only be visible if the endDate is populated. Otherwise I don't want it to be seen in the report.
I'm not sure what other information to provide, I think that's sufficient for you to understand my question.
Thanks,
When using knockout.js, you can use the visible binding to hide some content based on the end date:
<tr data-bind="visible: EndDate() != null">
<td class="ms-vb">
<b>End Date:</b>
</td>
<td class="ms-vb">
<span data-bind="text: EndDate"></span>
</td>
</tr>
You can use the visible binding, documented (with examples) here.

How to loop through list of items and present it in a fixed amount of columns

I want to loop throw list of items and to present them in away that each row has 3 columns
Using this code,
<t:dataTable var="itemInfo" value="#{itemBean.itemList}">
<h:column>
<h:outputText value="#{itemInfo.name}" />
</h:column>
</t:dataTable>
I'm able to present it on one column, but how can I present it on 3 columns?
For example, if I have 9 items A B C D E F G H I, then it should look like this:
A B C
D E F
G H I
You can use panelgrid with c:forEach like this:
<h:panelGrid columns="3">
<c:forEach items="#{itemBean.itemList}”" var="itemInfo">
<h:outputText value="${itemInfo.name}"/>
</c:forEach>
</h:panelGrid>
or you can use primefaces dataGrid or sth like that:
http://www.primefaces.org/showcase/ui/datagrid.jsf
Use panelgrid instead of datatable.
Regards

Resources