I have this sample table in jsfiddle.net how my table should look like
The second column can have more than one row that should coincide with the original columns. I am very confused how to achieve this using jstl <c:forEach>
This is the code I have written which prints everything in the same row because i don't have any break statements for the inner foreach but I want something similar to what I have in jsfiddle
<c:forEach items="${abc.bcd }" var="abc">
<tr>
<td align="center"><c:out value="${abc.interval }" /></td>
<td><c:out value="${abc.operation}" /></td>
<td>
<c:forEach items="${abc.parts.info}" var="info">
<c:out value="${info.number}" />
<c:out value="${info.quantity}" />
<c:out value="${info.name}" />
</c:forEach>
</td>
</tr>
</c:forEach>
I dunno how to detail the specs of how HTML based tables work, but the overall is rows within a single column isn't how it was developed to work. As the ration of rows with columns need to balance out in a matter of speaking.
If you have a column where you need the appearance of rows, your best bet it to place a new table within that column and build out the appearance of said rows within it
example:
<table>
<tr>
<td>
<table>
<tr>
<td>Info</td>
<td>Info</td>
<td>Info</td>
</tr>
</table>
</td>
</tr>
</table>
Looking at what you have constructed so far, it looks like you have a Map at abc.parts.info. If you have an ordered map, like a LinkedHashMap, you could iterate trough the map:
<c:forEach items="${abc.bcd}" var="abc">
<tr>
<td align="center"><c:out value="${abc.interval}" /></td>
<td><c:out value="${abc.operation}" /></td>
<c:forEach items="${abc.parts.info}" var="info">
<td><c:out value="${info.value}" /></td>
</c:forEach>
</tr>
</c:forEach>
If you have an unordered map, like a HashMap, you could just access values in your map using EL (assuming your keys are strings):
<c:forEach items="${abc.bcd}" var="abc">
<tr>
<td align="center"><c:out value="${abc.interval}" /></td>
<td><c:out value="${abc.operation}" /></td>
<td><c:out value="${abc.parts.info['number']}" /></td>
<td><c:out value="${abc.parts.info['quantity']}" /></td>
<td><c:out value="${abc.parts.info['name']}" /></td>
</tr>
</c:forEach>
Related
I have a Typo3(11.5.12) website, with a generated sitepackage and the Fluid Template Engine.
I want to create a dynamic table element in a custom template. It is supposed to create an element for each entry a user makes on a the page in Typo3.
I tried to implement this with a table and I want to make an iterator, that loops once for each element added to this table in the custom html layout. In the loop I want to create an option element containing the text of the table row and a custom ID.
I already made an Iterator with fluid, that loops for each element in an array, so maybe converting the table content to an array might work?
If there is another content module that fits better I would use that, I also considered a simple text element with an iterator for each line.
I made a variable content, which gets the content of said table in the setup.typoscript file.
The table:
The variable in setup.typoscript:
variables{
content < styles.content.get
}
The (current) content of the variable:
<div id="c21" class="frame frame-default frame-type-table frame-layout-0">
<table class="ce-table">
<tbody>
<tr> <td> Testkunde 1 </td> </tr>
<tr> <td> Testkunde 2 </td> </tr>
<tr> <td> Testkunde 3 </td> </tr>
<tr> <td> Testkunde 4 </td> </tr>
<tr> <td> Testkunde 5 </td> </tr>
<tr> <td> Testkunde 6 </td> </tr>
<tr> <td> Testkunde 7 </td> </tr>
<tr> <td> Testkunde 8 </td> </tr>
<tr> <td> Testkunde 9 </td> </tr>
<tr> <td> Testkunde 10 </td> </tr>
</tbody>
</table>
</div>
Snippet from the custom html layout, where I want to implement the iterator:
<table>
<tr>
<td>
<form>
<input type="hidden" name="id" value="4">
<input type="hidden" name="Select" value="All">
<select name="Nr" size="20" style="width:400px;">
<option value="1">Kunde 1</option>
<option value="2">Kunde 2</option>
<option value="3">Kunde 3</option>
<option value="4">Kunde 4</option>
<option value="99"> {content}</option>
<!--I want to create an option element
for each line of the table here-->
</select>
</form>
</td>
</tr>
</table>
When manually rendering a backend-created text table, I built my own fluid view helper for this that wraps TYPO3\CMS\Core\Utility\CsvUtility::csvToArray. Its result can easily be iterated on.
i am doing a program on selecting suitable link to user, by first accepting their input, such as main ingredient, cooking method , and allergies. i use database report (using database palette), and success generate the result. the problem is, if there is no result for that sql statement, i want to return error message. how do i do that using database report?
i'm using netbeans, glassfish, and mysql database.
here is my code:
<sql:query var="result" dataSource="jdbc/foodSys">
SELECT distinct Link FROM filtered
where maining = '<%=request.getParameter("cate_1")%>'
and cookmet='<%=request.getParameter("cate_2")%>'
and allergies='<%=request.getParameter("cate_5")%>'
</sql:query>
<table border="1">
<tr>
<c:forEach var="columnName" items="${result.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
</tr>
<c:forEach var="row" items="${result.rowsByIndex}">
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
Try choose when otherwise tags, and check for empty result.rows
<c:choose>
<c:when test="${empty result.rows}">
<p>Error Message</p>
</c:when>
<c:otherwise>
<table border="1">
<tr>
<c:forEach var="columnName" items="${result.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
</tr>
<c:forEach var="row" items="${result.rowsByIndex}">
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</c:otherwise>
</c:choose>
How can I update multiple textbox in database using ASP.NET Web Pages(razor syntax). I want to edit emails of students. And the number of rows containing textbox varies or dynamic. Somebody help.
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<tr>
<td>Jason</td>
<td><input type="text" name="txtbox1"></td>
</tr>
<tr>
<td>Kripkee</td>
<td><input type="text" name="txtbox2"></td>
</tr>
<tr>
<td>Kane</td>
<td><input type="text" name="txtbox3"></td>
</tr>
<tr>
<td>Michael</td>
<td><input type="text" name="txtbox4"></td>
</tr>
<tr>
<td><input type="submit" value="Update"></td>
</tr>
</table>
</form>
You can try this:
Assuming you have a view model providing a list of students.
View -
#foreach (var student in Model.Students)
{
<tr>
<td>#student.Name</td>
<td><input name="studentEmails[#student.Id]"/></td>
</tr>
}
Controller -
public ActionResult UpdateEmails(IDictionary<int, string> studentEmails)
I have a form on my cfm page, that is to insert a new row into an SQL datasource. The cfm page hosts the form - and when submitted the -action.cfm page inserts the data and relocates the user to a page listing the new information. The problem I am getting is when I submit the form I am getting:: Element NEWUSERID is undefined in FORM.
the form on the insertScores.cfm page:
<form method="post" action="insertScores-action.cfm">
<table>
<tr>
<td>User ID</td>
<td><input name="newUserID" type = "text" size = "50"></td>
</tr>
<tr>
<td>First Name</td>
<td><input name="newFirstName" type="text" size="50"></td>
</tr>
<tr>
<td>Last Name</td>
<td><input name="newLastName" type="text" size="50"></td>
</tr>
<tr>
<td>Email</td>
<td><input name="newEmailAdd" type="text" size="50"></td>
</tr>
<tr>
<td>Score</td>
<td><input name="newScore" type="text" size="50"></td>
</tr>
<tr>
<td>Pass Date</td>
<td><input name="newPassDate" type="text" size="50" value="dd/mm/yyyy"></td>
</tr>
<tr>
<td>Level</td>
<td><input name="newLevel" type="text" size="50"></td>
</tr>
<tr>
<td><input type="submit" value="Insert Scores"></td>
</tr>
</table>
The insertScores-action.cfm page
<cfquery name="insertScores" datasource="staffwrite">
INSERT INTO protinfo_scores (
userID
, first_name
, last_name
, email
, curr_score
, curr_score_date
, level
)
VALUES (
'#form.newUserID#'
, '#form.newFirstName#'
, '#form.newLastName#'
, '#form.newEmailAdd#'
, '#form.newScore#'
, '#form.newPassDate#'
, '#form.newLevel#'
)
</cfquery>
<cfquery name = "queryScore" datasource="staff">
SELECT userid, level
FROM protinfo_scores
WHERE userid LIKE '#form.newUserid#'
AND level = '#form.newLevel#'
</cfquery>
<cflocation URL="newScore.cfm?userid=#url.userid#&level=#url.level#">
newScore.cfm
<center>
<h2>Your ammendments have been made.</h2><hr>
</center>
<cfquery name = "queryScore" datasource="staff">
SELECT first_name, last_name, email, curr_score, curr_score_date, userid, level
FROM protinfo_scores
WHERE userid LIKE '#URL.userid#'
AND level = #URL.level#
</cfquery>
<cfoutput query="queryScore">
<table>
<tr bgcolor=beige>
<td>Name</td>
<td width="40">#queryScore.first_name# #queryScore.last_name#</td>
</tr>
<tr>
<td>Email</td>
<td width="40">#queryScore.email#</td>
</tr>
<tr bgcolor=beige>
<td>Username</td>
<td width="100">#queryScore.userid#</td>
</tr>
<tr>
<td>Level</td>
<td width="100">#queryScore.level#</td>
</tr>
<tr bgcolor=beige>
<td>Current Score</td>
<td width="40">#queryScore.curr_score#</td>
</tr>
<tr>
<td>Date Passed</td>
<td width="40">#queryScore.curr_Score_date#</td>
</tr>
</table>
</cfoutput>
and when submitted the -action.cfm page inserts the data and relocates
the user to a page listing the new information
I can't tell from the wording if this is the desired effect or the actual effect. If it is the actual effect, your error is occurring on newScore.cfm which would make sense because the data in the form scope does not persist after the cflocation and you're trying to use form.newUserID after the output table..
If this is the desired effect and NOT the actual effect...
As Dan said, you're looking at two different files. You show code from insertScores-application.cfm but your action is pointing to insertScores-action.cfm.
The code in your question is not exact copy/paste or even all of your code (you're missing a </form> tag to say the least). In this case I'd suggest showing us the actual code AND the error message. Many times I see element XXX is undefined in FROM (notice it says FROM and not FORM, something easy to miss when you're staring at the same thing for hours). The error message will tell you what line number the error is on. Is the line number actually among the code you posted?
I changed my <form></form> to a <cfform></cfform> and all now appears to work swimmingly. I was under the impression this would not make any difference but clearly it does.
How should I write line:
<a href="User?id=<c:out value="${user.id}" />" >Profile</a>
correctly? It shoult give me something like Profile
My context:
<c:forEach items="${requestScope.users}" var="user">
<tr>
<td><c:out value="${user.login}" /></td>
<td><c:out value="${user.name}" /></td>
<td><c:out value="${user.lastname}" /></td>
<td><a href="User?id=<c:out value="${user.id}" />" >Profile</a></td>
</tr>
</c:forEach>
Try ' inside " or vice versa
<a href="User?id=<c:out value='${user.id}' />" >Profile</a>
See image Here
This code should do
<td>Details</td>