I currently am making a table which has 8 columns. To start, I check if the value is null, if not null I write out a column title for the column (ex: "First Name:"). Next, I cycle through a list and populate each column with the appropriate value if it is not null. My issue is that the column headers (in between the comments in the code below) does not print while the actual data in the table does print. Can anyone help me?
<table style="width: 100%">
<c:choose>
<c:when test="${empty serviceRequests}">
</c:when>
<c:otherwise>
<tr> //DOES NOT PRINT STARTING FROM HERE
<td><c:choose>
<c:when test="${empty serviceRequestData['ID']}"></c:when>
<c:otherwise>
<u>ID:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['FN_Contact']}"></c:when>
<c:otherwise>
<u>First Name:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['LN_Contact']}"></c:when>
<c:otherwise>
<u>Last Name:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['Email']}"></c:when>
<c:otherwise>
<u>Email:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['FN_Reporter']}"></c:when>
<c:otherwise>
<u>Reporter First Name:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['LN_Reporter']}"></c:when>
<c:otherwise>
<u>Reporter Last Name:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['Company']}"></c:when>
<c:otherwise>
<u>Company:</u>
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['Notes']}"></c:when>
<c:otherwise>
<u>Notes:</u>
</c:otherwise>
</c:choose></td>
</tr> //DOES NOT PRINT ENDING HERE
<c:forEach var="serviceRequestData" items="${serviceRequests}">
<tr>
<td><c:choose>
<c:when test="${empty serviceRequestData['ID']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['ID']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['FN_Contact']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['FN_Contact']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['LN_Contact']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['LN_Contact']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['Email']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['Email']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['FN_Reporter']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['FN_Reporter']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['LN_Reporter']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['LN_Reporter']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['Company']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['Company']}
</c:otherwise>
</c:choose></td>
<td><c:choose>
<c:when test="${empty serviceRequestData['Notes']}">
Null
</c:when>
<c:otherwise>
${serviceRequestData['Notes']}
</c:otherwise>
</c:choose></td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
The variable you are trying to access in the table headers isn't defined until the <c:forEach> used to iterate over the data rows.
This should work:
<table style="width: 100%">
<c:choose>
<c:when test="${empty serviceRequests}"></c:when>
<c:otherwise>
<tr>
<td>
<u>ID:</u>
</td>
<td>
<u>First Name:</u>
</td>
<td>
<u>Last Name:</u>
</td>
<td>
<u>Email:</u>
</td>
<td>
<u>Reporter First Name:</u>
</td>
<td>
<u>Reporter Last Name:</u>
</td>
<td>
<u>Company:</u>
</td>
<td>
<u>Notes:</u>
</td>
</tr>
<c:forEach var="serviceRequestData" items="${serviceRequests}">
...
</c:forEach>
</c:otherwise>
</c:choose>
</table>
Of course you'll need to figure out what logic, (if any) that you want to use to wrap the header values.
Related
I have a table with a list of shows, my idea is to have a button that allows modifying each show:
...
<s:iterator value="%{listShow}" var="show">
<tr>
<td><s:property value="showId"></s:property></td>
<td><s:property value="showName"></s:property></td>
<td><s:property value="showDate"></s:property></td>
<td><s:property value="showPrice"></s:property></td>
<td><s:form action="goModify">
<s:submit value="Modify"></s:submit>
<s:hidden name="showId"></s:hidden>
<s:hidden name="showName"></s:hidden>
<s:hidden name="showDate"></s:hidden>
<s:hidden name="showPrice"></s:hidden>
</s:form></td>
</tr>
</s:iterator>
...
The only thing action "goModify" does is redirect to a modify.jsp file where I want to make the data changes:
<s:form action="modifyAction">
<s:textfield label="ID" name="showId" value="%{showId}"></s:textfield>
<s:textfield label="Show Name" name="showName" value="%{showName}></s:textfield>
<s:textfield label="Date" name="showDate" value="%{showDate}></s:textfield>
<s:textfield label="Price" name="showPrice"value="%{showPrice}></s:textfield>
<s:submit value="Modificar"></s:submit>
</s:form>
The problem that the filled fields do not appear to me.
You are only assigning a name to the hidden fields, not a value. You can use the attribute key instead of name. It will automatically generate HTML with the correct name and value.
<s:iterator value="%{listShow}" var="show">
<tr>
<td><s:property value="showId" /></td>
<td><s:property value="showName" /></td>
<td><s:property value="showDate" /></td>
<td><s:property value="showPrice" /></td>
<td>
<s:form action="goModify">
<s:submit value="Modify" />
<s:hidden key="showId" />
<s:hidden key="showName" />
<s:hidden key="showDate" />
<s:hidden key="showPrice" />
</s:form>
</td>
</tr>
</s:iterator>
If the action goModify does not store the parameters in the value stack (e. g. by storing them in attributes), you may have to change the JSP to access the request parameters directly.
<s:form action="modifyAction">
<s:textfield label="ID" name="showId" value="%{#parameters.showId}" />
<s:textfield label="Show Name" name="showName" value="%{#parameters.showName} />
<s:textfield label="Date" name="showDate" value="%{#parameters.showDate} />
<s:textfield label="Price" name="showPrice" value="%{#parameters.showPrice} />
<s:submit value="Modificar"></s:submit>
</s:form>
However, the best solution for the second JSP would also be to use key instead of name and value. But then you have to make sure to have the values on the value stack.
I am using Display Tag Library to be able to perform pagination and sorting of data. I know how to display one item per table cell in a regular table from a list but using Display tag library I am kind of stuck. It display everything in one table cell. Behind the scene display tag generates tr and td tags but I am confused how to show the following esignNumDocsone per table cell.
Hope the question is clear.
<display:column title="# of E-Sign Documents" class="displayColumns" >
<c:forEach items="${intgList}" var="list">
<c:if test="${list.policyNbrLink eq false}">
<td class="dataFieldCell1" align="center"><c:out value="${list.policyNumber}"/></td>
</c:if>
<a id="eSignNumDocs" href= "javascript:locateFunc('viewESignDetails', {'url':'<integration:urlAction actionName="/integration/viewDetailsIntegration"><integration:urlParam key="esignIdentifier" value="${list.esignId}"/></integration:urlAction>',
'agencyCode':'${list.agencyCode}',
'policyNumber':'${list.policyNumber}',
'policyState':'${list.policyState}',
'esignIdentifier':'${list.esignId}',
'esignVendorIdentifier':'${list.esignVendorIdentifier}',
'lob':'${list.lob}',
'transId':'${list.transId}',
'customerName':'${list.insuredName}',
'customerPhone':'${list.custPhone}',
'customerEmail':'${list.custEmail}',
'cretedDate':'${list.createdDate}'});">
<c:out value="${list.esignNumDocs}"/>
</a>
</c:forEach>
</display:column>
I need to show value of eSignNumDocs one per table cell but with the above code it shows 1,2in the cell. How can I show 1 in one row and 2 the next?
Thanks.
Alright guys, I thought this might help someone. Display tag also accepts implicit objects. Since it takes a list anyways I didn't need to iterate through again for the # of ESign docs column. Instead I used the table id which is data in my case and passed that to initialize all the variables in the URL. Following shows the complete code with the change.
<display:table id="data" name="intgList" requestURI="/integration/viewIntegration" class="fieldLabelCell" pagesize="10">
<!-- Setting table properties -->
<display:setProperty name="paging.banner.page.selected" value="{0}" />
<display:setProperty name="basic.empty.showtable" value="true"/>
<display:setProperty name="paging.banner.placement" value="top"/>
<display:setProperty name="basic.msg.empty_list_row" value=""/>
<display:setProperty name="paging.banner.group_size" value="2"/>
<display:setProperty name="paging.banner.no_items_found" value=""/>
<display:setProperty name="paging.banner.page.separator" value=" of "/>
<display:setProperty name="paging.banner.first" value='<span class="pagelinks"> |< << | Page {0} | >> >|</span>'/>
<display:setProperty name="paging.banner.last" value='<span class="pagelinks"> |< << | Page {0} | >> >| </span>'/>
<display:setProperty name="paging.banner.full" value='<span class="pagelinks"> |< << | Page {0} | >> >| </span>'/>
<!-- Displaying columns data -->
<display:column property="lob" title="Line of<br>Business" sortable="true" class="displayColumns" />
<display:column property="insuredName" title="Insured" sortable="true" class="displayColumns"/>
<display:column property="custPhone" title="Customer<br>Phone" sortable="true" class="displayColumns" />
<display:column property="policyNumber" title="Policy #" sortable="true" class="displayColumns" />
<display:column property="createdDate" title="E-Sign<br>Created Date" sortable="true" class="displayColumns" />
<display:column property="custEmail" title="Customer<br>Email" sortable="true" class="displayColumns" />
<display:column title="# of E-Sign Documents" class="displayColumns" >
<c:if test="${list.policyNbrLink eq false}">
<td class="dataFieldCell1" align="center"><c:out value="${list.policyNumber}"/></td>
</c:if>
<a id="eSignNumDocs" href= "javascript:locateFunc('viewESignDetails', {'url':'<integration:urlAction actionName="/integration/viewDetailsIntegration"><integration:urlParam key="esignIdentifier" value="${data.esignId}"/></integration:urlAction>',
'agencyCode':'${data.agencyCode}',
'policyNumber':'${data.policyNumber}',
'policyState':'${data.policyState}',
'esignIdentifier':'${data.esignId}',
'esignVendorIdentifier':'${data.esignVendorIdentifier}',
'lob':'${data.lob}',
'transId':'${data.transId}',
'customerName':'${data.insuredName}',
'customerPhone':'${data.custPhone}',
'customerEmail':'${data.custEmail}',
'cretedDate':'${data.createdDate}'});">
<c:out value="${data.esignNumDocs}"/>
</a>
</display:column>
</display:table>
I tried to decrease the height of the column by using following syntax:
<p:column style="height:10px;">
and the datatable row height won't decrease; it only increases if I set a bigger size.
Is there a way to make the height smaller than the default/existing one?
This is the exact code, that I'm using:
<c:forEach var="column" items="#{dispoFillingPage.columnListAuftrag}">
<c:choose>
<c:when test="${column.dateColumn}">
<p:column id="#{column.id}" filterStyleClass="#{column.filterStyleClass}" headerText="#{column.title}" visible="#{column.visible}"
width="#{column.width}" filterBy="#{data[column.property]}" sortBy="#{data[column.property]}" field="#{column.property}"
filterFunction="#{standortPage.filterByDate}" filterMatchMode="contains" style="height:10px">
<f:attribute name="rtcCol" value="#{column}" />
<h:outputText value="#{data[column.property]}">
<f:convertDateTime type="date" pattern="yyyy-MM-dd" />
</h:outputText>
</p:column>
</c:when>
<c:otherwise>
<p:column id="#{column.id}" filterStyleClass="#{column.filterStyleClass}" headerText="#{column.title}" field="#{column.property}"
visible="#{column.visible}" width="#{column.width}" filterBy="#{data[column.property]}" sortBy="#{data[column.property]}"
filterMatchMode="contains" style="height:10px;">
<f:attribute name="rtcCol" value="#{column}" />
<h:outputText value="#{data[column.property]}" />
</p:column>
</c:otherwise>
</c:choose>
</c:forEach>
I have to do this, because I have two datatables with 20 rows each and I have to make them fit in the screen, so that they are entirely visible to the user.
I had to decrease the font-style of the datatable in order to decrease also the row height.
<p:datatable style="font-size:8px">
But this way I decrease the entire datatable.
<table class="layout-table">
<tr>
<td><strong>3. Has the person completed all required training within the past three years?</strong><br/><br/></td>
</tr>
<tr>
<td><strong>a. Copy of It</strong>
<p:selectOneRadio id="radio3" value="#{question3a}">
<f:selectItem itemLabel="Yes" itemValue="0" />
<f:selectItem itemLabel="No" itemValue="1" />
<f:selectItem itemLabel="NA" itemValue="2" />
</p:selectOneRadio>
<br/>
<h:outputText id="counter3" />
</td>
</tr>
</table>
What I am trying to do is get a table to look like this
3. Has the person completed all required training within the past three years?
a. Copy of It Yes [] No[] NA[]
b. (another one) Yes [] No[] NA[]
I dont know how to tab the a and b and also if I make it where the buttons are to the right of the columns then it spaces it all the way to the very right hand side and I am not sure why.... Is this possible to do without CSS? If not then CSS would be fine too. Thanks for the help!
You might want to mark it up so it looks like this. I do agree that tables probably aren't the best solution for this problem.
<table class="layout-table">
<tr>
<td><strong>3. Has the person completed all required training within the past three years?</strong>
</tr>
<tr>
<td>
<table width="600" cellpadding="0" cellspacing="0" border="0" style="margin: 0 auto;">
<tr>
<td>
<p:selectOneRadio id="radio3" value="#{question3a}">
<f:selectItem itemLabel="Yes" itemValue="0" />
<f:selectItem itemLabel="No" itemValue="1" />
<f:selectItem itemLabel="NA" itemValue="2" />
</p:selectOneRadio>
</td>
</tr>
<tr>
<td>
<p:selectOneRadio id="radio3" value="#{question3a}">
<f:selectItem itemLabel="Yes" itemValue="0" />
<f:selectItem itemLabel="No" itemValue="1" />
<f:selectItem itemLabel="NA" itemValue="2" />
</p:selectOneRadio>
</td>
</tr>
</table>
</td>
</tr>
</table>
I want to convert html table to primeface datatable, I have converted some more table in my project but below code is bit complex so I need your help, here columns are created using different list and rows are from different list.
<table >
<thead>
<tr >
<th style="width:45px;">Id</th>
<th>#{msg['manage.relationship.type.name']}</th>
<c:forEach items="#{manageRelationBean.languageList}" var="languageName" >
<th>#{languageName}</th>
</c:forEach>
<th style="width:75px;">#{msg['manage.relationship.action']}</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{manageRelationBean.languageRelList}" var="languageRelDTO">
<tr>
<td>#{languageRelDTO.relationId}</td>
<td>#{languageRelDTO.relationName}</td>
<c:forEach items="#{languageRelDTO.languageList}" var="relationValues">
<td>#{relationValues.relationValue}</td>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</html>
Have you looked at the Showcase example? http://www.primefaces.org/showcase/ui/datatableBasic.jsf
Here is something like your example, for the first few columns. Notice the ForEach within the datatable- This will allow dynamic columns like you have.
<h:form>
<p:dataTable var="languageRelDTO" value="#{manageRelationBean.languageRelList}">
<p:column headerText="Id">
<h:outputText value="#{languageRelDTO.relationId}" />
</p:column>
<p:column headerText="#{msg['manage.relationship.type.name']}">
<h:outputText value="#{languageRelDTO.relationName}" />
</p:column>
<c:forEach items="#{manageRelationBean.languageList}" var="languageName">
<p:column headerText="#{languageName}" />
<h:outputText value="#{languageRelDTO.languageList[languageName.index]}" />
</p:column>
</c:forEach>
</p:dataTable>
</h:form>
Didn't test it, but you should get the idea.