How to use URL Rewriting within foreach loop? - html

<body>
<form>
<table>
<tr>
<th pic</th>
<th>rating</th>
</tr>
<c:forEach var="forumVO" items="${list}">
<tr>
<td><img src="<%=request.getContextPath()%>/forum/goforum?action=showImage&forum_no=${forumVO.forum_no}"></td>
<td><%=request.getContextPath()%>/forum/goforum?action=showRating&forum_no=${forumVO.forum_no}</td>
</tr>
</c:forEach>
</table>
</form>
above is a simple code which both tags uses url rewriting to send its information into the Servlet. but the one which has img tag is working good for showing the picture, but the second tag is not working properly, the html seems to see contents without <% %> and ${} as plain String objects, is there any ways to modify this code so the seconde tag can also sending its value to the Servlet?

<c:forEach var="forumVO" items="${list}">
<tr>
<td><img src="<%=request.getContextPath()%>/forum/goforum?action=showImage&forum_no=${forumVO.forum_no}"></td>
<td>${forumVO.forum_no}</td>
</tr>
</c:forEach>
the ${forumVO.forum_no} will print the number inside it no need to call the servlet again

Related

ng-bind-html with html + angularjs inside

In one of the pages of my app, I am using ng-bind-html to show some text through a function:
<ng-bind-html
ng-bind-html="getText(textContainer)">
</ng-bind-html>
getText() returns some text which is html code + some angularjs, something like:
<table>
<tbody>
<tr>
<td>
SOME TEXT
<textarea data-ng-bind-html="getOtherText(index)" data-ng-keyup="updateOtherText(index)</textarea>
</td>
</tr>
</tbody>
</table>
Now, I don't know if this is feasible (I am aware that it could be not particular good), but the second bind and the keyup don't seem to fire. Could someone explain me why please?

Row id's in html table

I have a jsp that displays a table of xml files and I want do display its content when I click on certain file in a table, but I dont know how to remember which row ID i clicked on so I know which file to display. This code displays table of files.
<table class="zakladni" border="1">
<thead>
<tr>
<th>Name</th>
<th>Version</th>
</tr>
</thead>
<s:useActionBean beanclass="org.cz.muni.fi.pb138.WARActionBean" var="actionBean"/>
<c:forEach items="${actionBean.getWARs()}" var="WAR">
<tr>
<td><c:out value="${WAR.getFileName()}"/></td>
<td><c:out value="${WAR.getTimestamp()} "/></td>
</tr>
</c:forEach>
</table>
The easiest solution is to generate an anchor (<a> element) directly into the table. That would look something like this:
<td>
<a href="fileDir/${WAR.getFileName()}">
<c:out value="${WAR.getFileName()} "/>
</a>
</td>
Where I suppose the file itself is stored in a directory fileDir, you can change it anyway you need.
I just hope you get the idea. And btw, greetings from Cuni!

Attaching an Href to a row inside a table

I am using html in a .php file to code. I have a statement:
<html>
<tr>
<td>Hi<td>
<td>Test<td.
</tr>
</html>
How can I attach an href to the row? Simply adding href in the tag didn't work. Anybody know how? Note: The table was defined earlier in the code this is the snip-it portion of the row.
You do not attach href to row instead you better do as
<table class="table table-stripped">
<tr class="selectedRow">
<td>Hi</td>
<td>Test</td>
</tr>
</table>
then using jquery :
$('.selectedRow').click(function(){
alert('do something');
});
View LiveWeave

Why does JSF's ui:repeat add invalid tags to my HTML?

In my JSF app's page template, I use ui:repeat to iterate over some data to build an HTML table. I want to use basic HTML tags for this rather than something like h:dataTable, because when I tried to apply some styles and JavaScript events to that, they didn't appear on the correct elements. However, when using ui:repeat for this purpose, I find that it adds invalid tr and td opening an closing tags at inappropriate places.
The page template, has code similar to this:
<table border="1" style="width: 100%;">
<ui:repeat var="row" value="#{bean.testData}">
<tr>
<ui:repeat var="column" value="#{bean.testData}">
<td>#{row}, #{column}</td>
</ui:repeat>
</tr>
</ui:repeat>
</table>
I actually want to do something more complex than this, but this is the simplest example of the problem.
The bean contains:
private final String[] testData = {"fu", "bar"};
public String[] getTestData() {
return this.testData;
}
The output of this is:
<table border="1" style="width: 100%;"></td>
</tr>
<tr>
<td>
<tr>
<td>fu, fu</td>
<td>fu, bar</td>
</tr>
<tr>
<td>bar, fu</td>
<td>bar, bar</td>
</tr></td>
</tr>
<tr>
<td>
</table>
What I expected the output to be is:
<table border="1" style="width: 100%;">
<tr>
<td>fu, fu</td>
<td>fu, bar</td>
</tr>
<tr>
<td>bar, fu</td>
<td>bar, bar</td>
</tr>
</table>
I can't figure out why JSF's adding this at the beginning and end of the ui:repeat loop's output:
</td>
</tr>
<tr>
<td>
In Google Chrome and Firefox, this causes an extra row containing a single, empty cell at the top and bottom of the table.
Any ideas of how to prevent this?
Update: I didn't think to mention that this table I'm generating will appear inside a h:panelGrid element. I don't know whether that will make a difference to this question or not.
As per the update, you need to encapsulate your code inside a JSF tag like this :
<h:panelGrid>
<ui:fragment>
<table border="1" style="width: 100%;">
<ui:repeat var="row" value="#{bean.testData}">
<tr>
<ui:repeat var="column" value="#{bean.testData}">
<td>#{row}, #{column}</td>
</ui:repeat>
</tr>
</ui:repeat>
</table>
</ui:fragment>
</h:panelGrid>
Ortherwise the rendering of the h:panelGrid will not be able to split correctly in cell the nested content. h:panelGrid is designed to handle JSF components only.
More info :
JSF 2 h:panelGrid documentation
JSF 2 h:panelGrid example

How do I grab info from source code from other site?

Is there a way to grab things out of the source code of another site directly into your site?
For example, let's say than in a site the following source code exists:
<table ...>
<tr>
<td class=...>...</div></td>
</tr>
<tr>
<td class=....><div align="... class=...>"Interesting string that keeps changing"</div></td>
</tr>
</table>
And we want that Interesting string that keeps changing to appear in our website as well.
you could use php
you use
$html = file_get_contents('url to website');
or use a hidden if you want a javascript function, and then just grab the innerhtml