Jslt c out in a href - html

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>

Related

Pre-filling search query's. POST Http

I'm trying to understand how to use query strings in URL's and trying to make some shortcuts to make my job easier. From what I've been reading here and there there are ways to pre-program a website using query parameters. I went to the website I'm interested and pulled the "search form" part that I would like to pre-fill (this is a database search, I would like to have a direct link that just pre-populates and just shows the results of the search instead of me filling it each time I look for new data).
This is from the website's "inspect source". the part of it:
<form id="partInquiry" name="partInquiry" action="PartInquiryForEdit.htm" method="post">
<table style="width: 40%">
<tr>
<td colspan="2" align="left"></td>
</tr>
<tr class="ez1">
<td class="label">Search By:
</td>
<td class="input"><select id="searchby" name="search">
<option value="part_number">Part Number</option><option value="part_description">Part Description</option><option value="rdo_gpl">RDO/GPL</option><option value="rdo_productCd">RDO/Product Code</option>
</select></td>
</tr>
<tr class="ez1">
<td class="label">Match By:
</td>
<td class="input"><select id="matchby" name="match">
<option value="matches">Exactly Matches</option><option value="contains">Contains</option><option value="startsWith">Starts With</option><option value="endsWith">Ends With</option>
</select></td>
</tr>
<tr class="ez1">
<td class="label">Search For:
</td>
<td class="input"><input id="searchfor" name="searchString" type="text" value="" maxlength="750"/> </td>
</tr>
<tr class="ez1">
<td colspan="2"><input type="submit" onclick="clearSession();"
value="Submit"
class="Button" /> <input type="submit"
value="Cancel"
class="Button" /></td>
</tr>
</table>
<BR>
<BR>
<table>
<tr>
<td><label class="errorBox" id="errorBox"></label>
<table>
<tr>
<td></td>
</tr>
</table>
<table>
<tr>
<td></td>
</tr>
</table> <input type="hidden" id="rowsToAdd" name="rowsToAdd" /> <input
type="hidden" id="rowsToRemove" name="rowsToRemove" /> <input
type="hidden" id="rowsToSubmit" name="rowsToSubmit" /> <input
type="hidden" id="isExport" name="isExport" />
<table>
<tr>
<td></td>
</tr>
</table> </td>
<td></td>
</tr>
</table>
<BR>
<BR>
</form>
I tried the following to no avail and I dont know how else to do it:
?search=part_description&searchby=part_description&matchby=contains&match=contains&searchfor=MYSEARCHSTRING&searchString=MYSEARCHSTRING&Submit
?search=part_description&match=matches&searchString=MYSEARCHSTRING&Submit&submit
?searchby=part_description&matchby=matches&searchfor=MYSEARCHSTRING
I'm not sure I'm understanding how to do this or if maybe there's somewhere in the code where It disables this (and how would I find it?). As shown, I tried using the "names" but nothing, I also tried using the "id"s but nothign either. Also I dont know how to actually "submit" the search since the submit button has no id or name. only an "onclick" and a "value".
Pre-populating a form via the query string is something that the website must explicitly support, it's not a general feature. The website must be coded to accept values on the query string and then return the appropriate HTML to pre-select those values.
If the website does not support this, then what you can do as an alternative is create a bookmarklet that populates the fields you want. For example:
javascript:var id=document.getElementById.bind(document);id('searchby').value='part_description';id('matchby').value='matches';id('searchfor')='MYSEARCHSTRING';void 0;
After you've loaded the site, you can click the bookmark to pre-fill the form.

how to display error message if there is no result from sql statement that generated by palette (database report) in jsp

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 to bind model to spring from tag radio button to populate list?

I am trying to bind list that is listOftriptransactions to radio button.in my case while update value,after click on radio button value is not get updated,it takes previous value.
<table>
<c:forEach items="${listOftriptransactions}" var="trans" varStatus="mystatus">
<tr>
<td>
<form:radiobutton path="${listOftriptransactions[mystatus.index].isReceived}" checked="checked" />yes
<form:radiobutton path="${listOftriptransactions[mystatus.index].isReceived}" checked="checked" />No
</td>
</tr>
</c:forEach>
</table>
If there is another solution please let me know.thanks in advance
Try this:
<table>
<c:forEach items="${listOftriptransactions}" var="trans" varStatus="mystatus">
<tr>
<td>
<form:radiobutton path="listOftriptransactions[${mystatus.index}].isReceived" value="true">Yes</form:radiobutton>
<form:radiobutton path="listOftriptransactions[${mystatus.index}].isReceived" value="false">No</form:radiobutton>
</td>
</tr>
</c:forEach>
</table>

Wrong URL syntax?

After combining some jsp url with bean parameter inside the link href attribute I am getting wrong representation. What can be wrong here?
Here is the code:
<form method="post" action="<c:url value="/rest/categories/add/category/to/${categoriesBean.currentCategoryKey}"/>">
<table>
<tr>
<td>Parent :</td>
<td id="parentKey"></td>
</tr>
<tr>
<td>Name :</td>
<td><input id="categoryName" type="text"/></td>
</tr>
</table>
</form>
Attached is the presentation:
Do it like this...not aware of jsp but it's the only quotes issue on line 1
<form method="post" action='<c:url value="/rest/categories/add/category/to/${categoriesBean.currentCategoryKey}"/>'‌​>

table inside a column

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>