我正在向Document添加一个字段:
doc.add(new TextField("productName", prod.getProductName(), Field.Store.YES));
Run Code Online (Sandbox Code Playgroud)
但是当我进行搜索并尝试排序时,我不按字母顺序排列:
Sort sorter = new Sort();
SortField sortField = new SortField("productName", Type.STRING, false);
sorter.setSort(sortField);
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?我如何按字母顺序排序?
我有一个JSON对象,我用ng-repeat重复,键是字符串,值是一个数组.我将每个值列为复选框.我想创建第二个对象,其中包含仅检查的复选框的列表.我想用键和值保留对象的结构.
我不确定如何正确地将它绑定到模型,以便保留结构.
这是我的HTML
<h3 >Dynamic data binding in AngularJS</h3>
<div ng-app ng-controller="Controller" class="container">
<h4>Inputs</h4>
<ul ng-repeat="(parent, values) in inputs">
<span>{{parent}} : </span>
<li ng-repeat="value in values"><label>{{value}}
<input type="checkbox" ng-model="output[parent]" ng-checked="output[parent]" value="value" >
</input></label>
</li>
</ul>
<h4>Outputs</h4>
<ul ng-repeat="(key,value) in inputs">
<li>
{{key}} : {{output[key]}}
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
和我的JS
function Controller($scope) {
$scope.output = {};
$scope.inputs = {'category': ['one','two','three'], 'color':['blue','green']};
}
Run Code Online (Sandbox Code Playgroud)
有一些简单的方法可以做到这一点吗?我觉得我错过了一些小事,这一切都很好用.
我以为我有我需要的一切,但是我收到了这个错误:
0:44:36,127 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."myapp.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myapp.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "myapp.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_51]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_51]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Error loading jboss-structure.xml from C:\jboss-as-7.1.1.Final\standalone\deployments\myapp.war\WEB-INF\jboss-deployment-structure.xml
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:277) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:249) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:134) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]
Message: Unexpected element '{urn:jboss:deployment-structure:1.2}jboss-deployment-structure' …Run Code Online (Sandbox Code Playgroud) 我有一个 django 应用程序,它有 angular 和 bootstrap。这是我的设置的定义方式:
# Django settings for studentsite project.
import os
PROJECT_DIR = os.path.dirname(__file__)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'texascompletesdb', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'postgres',
'PASSWORD': 'password',
'HOST': 'localhost', # Empty for localhost through domain …Run Code Online (Sandbox Code Playgroud) 就在今天,我开始学习Vuforia.我正在查看Image Targets代码并看到它来自com.qualcomm.vuforia.samples.SampleApplication.utils.Teapot显示茶壶.
和Teapot.java有:
public Teapot()
{
setVerts(); // has verticies
setTexCoords(); // coordinates
setNorms(); // normals
setIndices(); // and indices
}
private void setVerts()
{
double[] TEAPOT_VERTS = { 11.222200, 0.110300, 20.030291, 10.302300,
-4.461498, 20.030291, 10.152300, -4.397198, 20.644890,
11.059500, 0.110900, 20.644890, 11.059500, ...
}
Run Code Online (Sandbox Code Playgroud)
我没有OpenGL的经验,我想知道如何创建自己的模型/网格来替换茶壶.我在Blender中创建了一个简单的框,但我没有很好的方法将它导出到一个包含verts,normals等的java文件.大部分内容都是针对iPhone以及如何创建.h文件.
我正在寻找的是对顶点,坐标,规范和索引的解释,或者是在另一个程序中创建对象的系统方法,并且能够将其导出以用于Vuforia.
我有一个名为test的无序列表
<ul id='test'></ul>
Run Code Online (Sandbox Code Playgroud)
它通过ajax动态填充数据.每个项目'li'都是包含'p'段落的div.每个段落都包含一些信息.
例如:
<li> <div> <p> test </p> </div> </li>
<li> <div> <p> hi how is it going?</p> </div> </li>
<li> <div> <p> not a test</p> </div> </li>
<li> <div> <p> whoa</p> </div> </li>
Run Code Online (Sandbox Code Playgroud)
我还有一个搜索框,我可以从中获取搜索词,我使用:
var searchTerm = $("#search").val().trim().split(' '); // an array of words searched for
Run Code Online (Sandbox Code Playgroud)
我想要做的是找到一种方法来选择包含所有或部分搜索词的所有"li"元素,但我不确定如何最好地处理它.
目前,我这样做:
var results = $('p:contains("'+ searchTerm[0] +'")');
Run Code Online (Sandbox Code Playgroud)
在第一个学期获得完全匹配,但我想搜索多个术语,而不只是一个.
我想搜索'test hi'并返回三个节点,因为它搜索'test'和'hi'.我还想到了:
var results2 = $('p').filter(function( index ) {
return ( this +':contains("'+ searchTerm +'")' );
});
Run Code Online (Sandbox Code Playgroud)
有人指出我正确的方向吗?
我有一个'初学者'的问题.为什么会出错?我在代码中调用该函数,但该函数被进一步定义.
AngularJS版本:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.name = 'Someone';
$scope.doStuff(); // run the defined function, but errors out
$scope.doStuff= function(){ // function definition
console.log('did something');
}
}
Run Code Online (Sandbox Code Playgroud)
但这个工作正常:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.name = 'Someone';
$scope.doStuff = function(){
console.log('did something');
}
$scope.doStuff();
}
Run Code Online (Sandbox Code Playgroud)
我有以下内容,我确信这里有一些简单的解决方案,我只是在俯视.我正在将数据加载到模型中,但它没有更新输入字段.
<div ng-app>
<h2>Testing</h2>
<div ng-controller="MyCtrl">
From: <input name="Price" type="number" ng-model='object.number["From"]' />
To: <input name="Price" type="number" ng-model='object.number["To"]' />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和JavaScript:
function MyCtrl($scope) {
$scope.object = {number : {}};
$scope.object['number'] = {From: null, To: null}
console.log($scope.object['number']);
$scope.loadPrice = function(){
$scope.object['number'].From = "5";
$scope.object['number'].To = "5";
}
$scope.loadPrice();
console.log($scope.object['number'])
}
Run Code Online (Sandbox Code Playgroud)
包括小提琴:
我有一个日期,我想将其转换为字符串,但没有时间,只有日期部分。
我当前的代码:
var date = new Date(2014, 9, 08); //Wed Oct 08 2014 00:00:00 GMT-0500 (Central Daylight Time)
var options = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
console.log(date.toLocaleTimeString("en-US", options));
// output: Wednesday, October 8, 2014 12:00:00 AM
// what I'm looking for: Wednesday, October 8, 2014
Run Code Online (Sandbox Code Playgroud)
如何修改选项以不显示时间?
这是我被问到的问题,我想知道该怎么做或者这是一个技巧问题.我一直只使用JavaScript一段时间,所以我不太确定.
假设您有一个包含大量内容的网页.不使用任何库或getElementsByClassName,遍历DOM并查找具有特定类名的所有元素.
示例HTML
<body>
<div>
<div class='myTarget'>
Target exists here
</div>
</div>
<div>
<table>
<tbody>
<tr> <td class='myTarget'> Target exists here </td> </tr>
</tbody>
</table>
</div>
<div>
<span class='myTarget notSameAsTarget'>Stuff<span>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
我的第一个想法是,这应该是一个递归函数,应该从根开始 document.documentElement
JS:
var root = document.documentElement;
var targetClass = 'myTarget';
var elementsWithTargetClass = []; // store in array
function traverse(element, targetClassName){
// get class of current element
var currentClass = element.className;
// add to array if class matches
if(currentClass.trim() === targetClassName)
elementsWithTargetClass.push(element);
// recursive call …Run Code Online (Sandbox Code Playgroud)