是否有一个通用的JavaScript函数来检查变量是否有值并确保它不是undefined
或null
?我有这个代码,但我不确定它是否涵盖了所有情况:
function isEmpty(val){
return (val === undefined || val == null || val.length <= 0) ? true : false;
}
Run Code Online (Sandbox Code Playgroud) 我有批处理文件,在我编写代码时为我设置桌面环境.该文件名为:SetEnv.cmd
并打开其他3个窗口:
以下是内容SetEnv.cmd
:
Explorer /n,c:\develop\jboss-4.2.3.GA\server\default\deploy
Explorer /n,c:\develop\Project\Mapping\deploy
cmd /c SetupEnvCmd.cmd
Run Code Online (Sandbox Code Playgroud)
以下是以下内容SetupEnvCmd.cmd
:
cd C:\develop\jboss-4.2.3.GA\bin
run
Run Code Online (Sandbox Code Playgroud)
每次我运行这个,我都要浪费时间重新安排和调整窗口大小.我不希望将窗口最小化,因为我在编写和测试代码时多次与每个窗口交互.有什么方法可以控制从脚本中打开的窗口的位置和/或大小?
我已经使用Bootstrap 3
了一段时间,现在我需要为水平移动设备制作一组新的额外小柱(例如384px
屏幕宽度),然后使用它如下:
col-xxs-1
,col-xxs-2
,col-xxs-offset-5
,hidden-xxs
,等.
是否有一些Bootstrap
Less
mixins用于此目的?我不确定如何使用它们
编辑:
有一个Bootstrap
混合调用.make-grid()
,但我不能使它工作.
是什么区别:data-sly-use
,data-sly-resource
,data-sly-include
,和data-sly-template
?我正在阅读文档Sightly
AEM
,我非常困惑.
据我所知:
data-sly-use
用于添加js/java
要使用doc呈现的文件data-sly-resource
用于注入组件data-sly-include
用于包含其他html文件(?***?)并且,数据狡猾模板令人困惑,如:
<div data-sly-use.nav="navigation.js">${nav.foo}</div>
<section data-sly-include="path/to/template.html"></section>
<template data-sly-template.one>blah</template>
<div data-sly-call="${one}"></div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Java以编程方式从XSD文件生成JAXB类.我使用以下代码片段来实现:
....
import java.io.File;
import java.io.IOException;
import org.xml.sax.InputSource;
import com.sun.codemodel.JCodeModel;
import com.sun.tools.xjc.api.S2JJAXBModel;
import com.sun.tools.xjc.api.SchemaCompiler;
import com.sun.tools.xjc.api.XJC;
....
....
public static void generateJaxb(String schemaPath,
String outputDirectory,
String packageName) throws DataLoadingException
{
try {
// Setup schema compiler
SchemaCompiler sc = XJC.createSchemaCompiler();
sc.forcePackageName(packageName);
// Setup SAX InputSource
File schemaFile = new File(schemaPath);
InputSource is = new InputSource(schemaFile.toURI().toString());
// Parse & build
sc.parseSchema(is);
S2JJAXBModel model = sc.bind();
JCodeModel jCodeModel = model.generateCode(null, null);
jCodeModel.build(new File(outputDirectory));
} catch (IOException exec) {
LOGGER.error("Error while generating JAXB …
Run Code Online (Sandbox Code Playgroud) 在对应用程序进行一些更改之后,它遭受了显着的性能下降,并且在调查中,最常调用的方法之一不再被编译.启用:-XX:+LogCompilation
显示在更改之前,此方法是:排队进行编译,编译,然后成功内联到调用者; 而在更改之后,没有编译尝试的记录,并且内联尝试说:
inline_fail reason ='not compilable(disabled)'
原始方法如下,其中_maxRepeats
一个实例变量声明为a Map
(没有泛型,很久以前编写的代码),使用的是键是类的对象,DadNode
值是a Integer
.
private int cnsGetMaxRepeats(DadNode dn) {
if (_maxRepeats != null) {
Integer max = (Integer)_maxRepeats.get(dn);
if (max != null) {
return max;
}
}
return dn.getMaxOccurs().getValue();
}
Run Code Online (Sandbox Code Playgroud)
修正案涉及将_maxRepeats
地图更改为使用泛型:
Map<Integer, Integer>
Run Code Online (Sandbox Code Playgroud)
并在方法中添加了一个新参数:
private int cnsGetMaxRepeats(int childIdx, DadNode dn) {
if (_maxRepeats != null) {
Integer max = _maxRepeats.get(childIdx);
if (max != null) {
return max;
}
}
return dn.getMaxOccurs().getValue();
}
Run Code Online (Sandbox Code Playgroud)
使用显式调用Integer.valueOf
和 …
我目前正在使用给定的代码,但这仅限于向一个国家/地区提出建议.我见过一个实现,但它使用jQuery,我想在不使用jQuery的情况下完成它.
var input = document.getElementById('searchTextField');
var options = {
//types: ['(cities)'],
componentRestrictions: { country: 'pk' }
};
var autocomplete = new google.maps.places.Autocomplete( input, options );
Run Code Online (Sandbox Code Playgroud) google-maps autocomplete google-maps-api-3 google-places-api
以下代码显示奇怪的输出.我应该看一个全屏移动地图.但出于某种原因,它只显示在屏幕的一部分上.我正在使用jquery.ui.map进行映射.
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.map.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content" id="map_canvas" name="contentMain">
</div><!-- /content -->
</div><!-- /page -->
<script>
$('#map_canvas').gmap().bind('init', function() {
// This URL won't work on your localhost, so you need to change it
// see http://en.wikipedia.org/wiki/Same_origin_policy
$.getJSON( 'http://jquery-ui-map.googlecode.com/svn/trunk/demos/json/demo.json', function(data) {
$.each( data.markers, function(i, marker) {
$('#map_canvas').gmap('addMarker', { …
Run Code Online (Sandbox Code Playgroud) 我正在使用下面的代码来获取两点之间的路线:
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我不想在绘制路线时更改我的地图位置和缩放级别.因此,当我使用不同的纬度和经度值调用上面的代码时,我希望保持我的地图位置和缩放级别.任何的想法?
我有以下课程:
@SuperBuilder(toBuilder = true)
public abstract class Parent {
//...
}
@SuperBuilder(toBuilder = true)
public class Child extends Parent {
//...
}
@SuperBuilder(toBuilder = true)
public class Child2 extends Parent {
//...
}
Run Code Online (Sandbox Code Playgroud)
为什么我无法调用toBuilder()
抽象类 ( ) 的实例Parent
,如以下代码所示?
public copy(Parent parent) {
parent.toBuilder().build();
}
Run Code Online (Sandbox Code Playgroud) java ×3
google-maps ×2
javascript ×2
aem ×1
autocomplete ×1
batch-file ×1
cmd ×1
jaxb ×1
jaxb2-basics ×1
jquery ×1
jvm-hotspot ×1
less ×1
lombok ×1
mixins ×1
null ×1
sightly ×1
undefined ×1
xjc ×1