I am trying to pass parameters from my input text control to the called xquery by adding them as parameters in url. I tried doing in may ways - always without success. Could you have a look and tell me what I am doing wrong?
xquery version "3.0";
declare option exist:serialize "method=xhtml media-type=application/xhtml+xml indent=yes";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";
declare variable $collection as xs:string := '/db/junitReports';
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:bf="http://betterform.sourceforge.net/xforms" xmlns:xf="http://www.w3.org/2002/xforms" bf:toaster-position="tl-down">
<head>
<title>IB interfaces regression testing report</title>
<meta name="author" content="test"/>
<meta name="author" content="test"/>
<meta name="description" content="IB interfaces regression testing report"/>
<link rel="stylesheet" type="text/css" href="styles/demo.css"/>
<!-- INPUT CONTROLS -->
<xf:model>
<xf:instance id="default">
<data xmlns="">
<InterfaceName constraint="true" readonly="false" required="false" relevant="true">
</InterfaceName>
<trigger1 constraint="true" readonly="false" required="false" relevant="true">
</trigger1>
</data>
</xf:instance>
<xf:instance id="table" xmlns="">
<data>
</data>
</xf:instance>
<xf:bind nodeset="InterfaceName" type="string">
</xf:bind>
<xf:submission id="showTable"
method="post"
action="{concat('/exist/rest/db/xquery/returnTable.xq?interface=',InterfaceName)}"
replace="instance"
ref="instance('table')"
instance="table">
</xf:submission>
</xf:model>
</head>
<body class="soria" style="margin:30px;">
<div class="Headline">IB test report</div>
<div class="description">
<p>You can restrict report output:</p>
</div>
<p>2. By typing in particular interface name</p>
<div class="Interface">
<xf:input id="InterfaceName" ref="InterfaceName" incremental="false">
<xf:label></xf:label>
<xf:hint>(S|R)xxxxxYYYZZZ</xf:hint>
<xf:help>Enter interface name</xf:help>
<xf:alert>Enter interface name</xf:alert>
</xf:input>
</div>
<br/>
<div>
<xf:trigger id="trigger1" ref="trigger1" incremental="true">
<xf:label>Filter output</xf:label>
<xf:hint>a Hint for this control</xf:hint>
<xf:help>help for trigger1</xf:help>
<xf:action ev:event="DOMActivate">
<xf:send submission="showTable"/>
</xf:action>
</xf:trigger>
</div>
<div>
<table border="1">
<thead>
<tr>
<th>Inteface Name</th>
<th>Test Date</th>
<th>Test Result</th>
<th>Report Link</th>
</tr>
</thead>
<tbody xf:repeat-nodeset="instance('table')//result">
<tr>
<td>
<xf:output ref="interfaceName"></xf:output>
</td>
<td>
<xf:output ref="reportDate"></xf:output>
</td>
<td>
<xf:output ref="testResult"></xf:output>
</td>
<td>
<li>
<xf:output ref="fileLink"></xf:output>
</li>
</td>
</tr>
</tbody>
</table>
</div>
<label>{InterfaceName}</label>
</body>
</html>
My uri remains without parameters:
"resource-uri":"http://localhost:8080/exist/rest/db/xquery/returnTable.xq?interface="
The right way to do it was to replace action attribute with this element in submission:
<xf:resource value="concat('/exist/rest/db/xquery/returnTable.xq?interface=',instance('defaultInstance')//InterfaceName,'&','date=',instance('defaultInstance')//CalendarDate)"/>
Related
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Achievements</title>
</head>
<body>
<h2>수료증 및 수상 내역</h2>
<hr>
<ul>
<h3><li>수료증</li></h3>
<table border="1">
<tr>
<th>과목명</th>
<th>교수명</th>
<th>대학명</th>
</tr>
<tr>
<td>Programming for Everybody(Getting Started with Python)</td>
<td>Charles Severance</td>
<td>University of Michigan</td>
</tr>
</table>
<h3><li>수상내역</li></h3>
<table border="1">
<tr>
<th>대회명</th>
<th>수상일</th>
</tr>
<tr>
<td>The 5th MIRROR Essay Contest</td>
<td>11/23/15</td>
</tr>
</table>
</ul>
<hr>
메인으로
</body>
</html>
I'm using Eclipse Jee Mars btw, and I get warnings saying "Multiple annotations found at this line: Invalid location of tag (h3), Invalid location of tag (h3)" and "Invalid location of (table)". When I open the file through Internet explorer it works fine. What's the problem and how should I fix it?
How can I get/set checkbox value using jstl and delete only those record from the database where the checkbox is checked? can you also advise how to use ternary operators in jstl for this scenario?
SearchStudent.jsp
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lookup Students</title>
</head>
<form method="post" action="deleteStudentServlet" class="form">
<body class="body">
<!-- List results -->
<c:if test="${not empty studentList}">
<table border="1" cellspacing="0" cellpadding="0" :>
<tr>
<th></th>
<th>ID</th>
<th>Title</th>
<th>First Name</th>
<th>Last Name</th>
<th></th>
</tr>
<c:forEach var="students" items="${studentList}">
<tr>
<td><input type="checkbox" name="chkBox"> </td>
<td>${students.studentID}</td>
<td>${students.title}</td>
<td>${students.firstName}</td>
<td>${students.lastName}</td>
<td><c:url value="UDS" var="url">
<c:param name="StudentID" value="${students.studentID}" />
</c:url> Edit</td>
</tr>
</c:forEach>
</table>
</c:if>
<td><input type="submit" name="submit" value="Delete" ></td>
</form>
<p>There are ${fn:length(studentList)} results.</p>
</body>
</html>
thanks.
Your checkbox has currently no value associated with the parameter name at all:
<input type="checkbox" name="chkBox">
So it's hard to find out the checked ones. You need to give the checkbox a value which uniquely identifies the selected item. In your particular example, the student ID seems to be an obvious choice:
<input type="checkbox" name="selected" value="${student.studentID}">
(by the way, why are you duplicating the entity name in the property name? why not just name it id so that you can just self-documentary use ${student.id}? also your var="students" is kind of odd, it is referring only one student, so just name it var="student"; the ${studentList} can better be named ${students})
When the form is submitted, all checked value are available as follows:
String[] selectedStudentIds = request.getParameterValues("selected");
Finally, just pass it through to your DAO/service class which does the business job:
studentService.delete(selectedStudentIds);
See also:
How to transfer data from JSP to servlet when submitting HTML form
ServletRequest.getParameterMap() returns Map<String, String[]> and ServletRequest.getParameter() returns String?
Send an Array with an HTTP Get
this may help you.
In ajax call:
var boolValue= $(this).closest(".tr").find('.checkboxClass').is(':checked');
$.post("/api/dosomething", {
someSettings : boolValue
})
I'm new to thymeleaf and am trying to make a simple table using an array and an each loop.
My code looks like this:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Smoke Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<table border="1" style="width:300px">
<tr>
<td>Test Name</td>
</tr>
<tr th:each="smokeTest : ${smokeTests}">
<td>
th:text="${smokeTest.name}">A Smoke Test'
</td>
</tr>
</table>
</body>
</html>
Basically my problem is that I can't run the loop as <td>s within <tr>s. Is there any way that this code could work?
You must put th:text as an attribute of a tag, so
<tr th:each="smokeTest : ${smokeTests}">
<td th:text="${smokeTest.name}">A Smoke Test'</td>
</tr>
should run.
Simple solution which comes to mind first:
<th:block th:each="smokeTest : ${smokeTests}">
<tr>
<td th:text="${smokeTest.name}">A Smoke Test'</td>
</tr>
</th:block>
Details: http://www.thymeleaf.org/whatsnew21.html#bloc
Although, it's late answer.
It's work more specifically, like
<tr th:each="smokeTest : ${smokeTests}">
<td><p th:text="${smokeTest.name}"></p></td>
</tr>
I'm stumped and can't find the bug.
Angular is working, because it's reading my {{expressions}}, however, it's not replacing them with the content I'm expecting. It's simply removing them and blanks sit in their place.
I'm sure this issue is also tied in with, for some reason, my ng-repeat directive isn't working. (It's not repeating.)
Can someone help me out? I'm trying to draw a table. In this example, when it's done, it should have the respective "idea" posted multiple times across the same row, and each row should have a different "idea", as listed in the $scope.
It's creating one single row filled with blanks (rather than {{idea}} ).
index.html
<!doctype html>
<html ng-app="AppName">
<head>
<link rel="stylesheet" type="text/css" href="styles/table.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</head>
<body>
<div ng-controller="TableController">
<table>
<tr>
<td>
<table cellspacing="0">
<tr class="title_bar">
<td>Title</td>
<td>Rating</td>
<td>Votes</td>
<td>Comments</td>
<td>Post Date</td>
<td>Status</td>
</tr>
</table>
</td>
</tr>
<div ng-repeat="idea in ideas">
<tr style="color: white">
<td>{{idea}}</td>
<td>{{idea}}%</td>
<td>{{idea}}</td>
<td>{{idea}}</td>
<td>{{idea}}</td>
<td>{{idea}}</td>
</tr>
</div>
</table>
</div>
<script src="scripts/controllers/TableController.js"></script>
</body>
</html>
TableController.js
var app = angular.module('AppName', []);
app.controller('TableController', ['$scope',function($scope){
$scope.ideas = [
'wow',
'cool',
'so nice',
'amazing',
'please work'
];
}]);
I'm probably missing something obvious but I appreciate any help you could give me.
Edit: Whoops, guess I need to brush up on my HTML basics.
Well, your HTML layout looks pretty strange. You shouldn't put <div> between <tr>
Try something like this:
<table>
<tr class="title_bar">
<td>Title</td>
<td>Rating</td>
<td>Votes</td>
<td>Comments</td>
<td>Post Date</td>
<td>Status</td>
</tr>
<tr ng-repeat="idea in ideas">
<td>{{idea}}</td>
<td>{{idea}}%</td>
<td>{{idea}}</td>
<td>{{idea}}</td>
<td>{{idea}}</td>
<td>{{idea}}</td>
</tr>
</table>
Fiddle demo
What you have is invalid HTML, so it's not rendering how you expect it to. You can't put a <div> inside a <table> and have it contain elements; you can include a <div> inside a <td> element but that doesn't really help you.
If you want to use ng-repeat in a table use it in <tr> or <tbody>
<tr ng-repeat="idea in ideas">
<td>{{idea}}</td>
........
</tr>
Try adding the ng-repeat directive to the td itself.
<tr>
<td ng-repeat="idea in ideas">{{idea}}</td>
</tr>
That should iterate through your $scope.ideas array.
I'm reading a local HTML document with Nokogiri like so:
f = File.open(local_xml)
#doc = Nokogiri::XML(f)
f.close
#doc contains a Nokogiri XML object that I can parse using at_css.
I want to modify it using Nokogiri's XML::Node, and I'm absolutely stuck. How do I take this Nokogiri XML document and work with it using node methods?
For example:
#doc.at_css('rates tr').add_next_sibling(element)
returns:
undefined method `add_next_sibling' for nil:NilClass (NoMethodError)
despite the fact that #doc.class is Nokogiri::XML::Document.
For completeness, here is the markup I'm trying to edit.
<html>
<head>
<title>Exchange Rates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table class="rates">
<tr>
<td class="up"><div></div></td>
<td class="date">Saturday, Jan 12</td>
<td class="rate up">3.83</td>
</tr>
<tr>
<td class="up"><div></div></td>
<td class="date">Friday, Jan 11</td>
<td class="rate up">3.70</td>
</tr>
<tr>
<td class="down"><div></div></td>
<td class="date">Thursday, Jan 10</td>
<td class="rate down">3.68</td>
</tr>
<tr>
<td class="down"><div></div></td>
<td class="date">Wedensday, Jan 9</td>
<td class="rate down">3.70</td>
</tr>
<tr>
<td class="up"><div></div></td>
<td class="date">Tuesday, Jan 8</td>
<td class="rate up">3.66</td>
</tr>
</table>
</body>
</html>
This is an example how to do what you are trying to do. Starting with f containing a shortened version of the HTML you want to parse:
require 'nokogiri'
f = '
<html>
<head>
<title>Exchange Rates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table class="rates">
<tr>
<td class="up"><div></div></td>
<td class="date">Saturday, Jan 12</td>
<td class="rate up">3.83</td>
</tr>
</table>
</body>
</html>
'
doc = Nokogiri::HTML(f)
doc.at('.rates tr').add_next_sibling('<p>foobar</p>')
puts doc.to_html
Your code is incorrectly trying to find the class="rates" parameter for <table>. In CSS we'd use .rates. An alternate way to do it using CSS is table[class="rates"].
Your example didn't define the node you were trying to add to the HTML, so I appended <p>foobar</p>. Nokogiri will let you build a node from scratch and append it, or use markup and add that, or you could find a node from one place in the HTML, remove it, and then insert it somewhere else.
That code outputs:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exchange Rates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table class="rates">
<tr>
<td class="up"><div></div></td>
<td class="date">Saturday, Jan 12</td>
<td class="rate up">3.83</td>
</tr>
<p>foobar</p>
</table>
</body>
</html>
It's not necessary to use at_css or at_xpath instead of at. Nokogiri senses what type of accessor you're using and handles it. The same applies using xpath or css instead of search. Also, at is equivalent to search('some accessor').first, so it finds the first occurrence of the matching node.
Try to load as HTML instead of XML Nokogiri::HTML(f)
Not getting in much detail on how Nokogiri works, lets say that XML does not have css right? So the method at_css doesn't make sense (maybe it does I dunno). So it should work loading as Html.
Update
Just noticed one thing. You want to do at_css('.rates tr') insteand of at_css('rates tr') because that's how you select a class in css. Maybe it works with XML now.