在HTML5 Canvas中,offsetTop和offsetLeft是什么?
我正试图获得鼠标点击事件的X和Y. 我知道我可以通过:
mycanvas.onclick = function (evt) {
var offX = evt.layerX - mycanvas.offsetLeft;
var offY = evt.layerY - mycanvas.offsetTop;
}
Run Code Online (Sandbox Code Playgroud)
但是什么是offsetLeft和offsetTop?什么是LayerX和LayerY?
我有一个登录页面,我想添加"记住我"功能; 这样,如果用户注销并再次打开页面,则会加载他的用户名和密码.为此,当用户登录(并"选中"记住我")时,我保存以下cookie:
FacesContext facesContext = FacesContext.getCurrentInstance();
Cookie userCookie = new Cookie("vtusername", username);
userCookie.setMaxAge(3600);
((HttpServletResponse) facesContext.getExternalContext()
.getResponse()).addCookie(userCookie);
Cookie passCokie = new Cookie("vtpassword", password);
passCokie.setMaxAge(3600);
((HttpServletResponse) facesContext.getExternalContext()
.getResponse()).addCookie(passCokie);
Run Code Online (Sandbox Code Playgroud)
问题是后来(在同一个会话中)我读了cookie,我看到maxAge = -1; 即使我把它设置为3600 ......为什么?另一个问题:如果我使用userCookie.setSecure(true)设置cookie安全,那么我无法读取它(它消失了).
另一个问题:由于密码存储在cookie中,我应该如何对其进行加密?什么是最佳做法?
提前致谢
我有一个支持多语言的java应用程序.当我更改语言时(在首选项对话框中),整个应用程序的语言会发生变化,包括Swing组件的语言JFileChooser.这适用于英语,西班牙语和法语.但是当我选择荷兰语时,Swing组件的语言(JFileChooser,确认对话框等)会改为英语.
下面是将语言更改为荷兰语的代码.备注:对于其他语言,我使用相同的代码("NL"当然除了字符串),它工作正常.
Locale locale = new Locale("nl");
Locale.setDefault(locale);
JComponent.setDefaultLocale(locale);
Run Code Online (Sandbox Code Playgroud)
我也尝试使用new Locale("nl", "BE");和创建语言环境,new Locale("nl", "NL");但没有一个工作.荷兰语语言环境有问题吗?或者我在这里做错了什么?
我有一个primefaces对话框,我可以在其中创建或更新Employee.它会打开
</p:dialog><p:dialog id="employeeEditDialog" header="#{msg.employeeEdit}"
widgetVar="dlgEmployeeEdit" resizable="false">
<p:ajax event="close" listener="#{employeeView.cancel}"
update=":showEmployees:liste" />
<ui:include src="/content/Employee/ShowEmployeeContent.xhtml" />
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
这是Dialog Page
<h:form id="editContent">
<p:growl id="growl" showDetail="true" sticky="false" life="5000" />
<p:focus id="focusEdit" for="emSalutation" />
<h:panelGrid columns="2" id="contentGrid">
<h:panelGrid columns="2" id="allgemein"> <h:outputText value="#{msg.id}" />
<h:outputText value="#{employeeView.newEmployee.id}" />
<h:outputText value="#{msg.salutation}" />
<p:selectOneMenu value="#{employeeView.newEmployee.salutation}"
id="emSalutation">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{employeeView.salutations}" var="salutations"
itemLabel="#{salutations.description}" itemValue="#{salutations}" />
</p:selectOneMenu>
<h:outputText value="#{msg.title}" />
<p:inputText value="#{employeeView.newEmployee.title}" id="emTitle" />
<h:outputText value="#{msg.name}" />
<p:inputText value="#{employeeView.newEmployee.name}" id="emName"
validatorMessage="#{msg.valName}" />
<h:outputText value="#{msg.prename}" />
<p:inputText value="#{employeeView.newEmployee.prename}"
id="emPrename" /> …Run Code Online (Sandbox Code Playgroud) 我的实体类中有一个LocalDateTime属性,但是当它被序列化时,我看不到预期的格式.
这是班级:
public class MyEntity {
private Integer id;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
private LocalDateTime changeDate;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
这就是杰克逊格式化的方式:
{
"id": 56,
"changeDate": {
"hour":14, "minute":19,
"nano":797000000,
"second":7,
"dayOfMonth":24,
"dayOfWeek":"TUESDAY",
"dayOfYear":297, "month":"OCTOBER",
"monthValue":10,
"year":2017,
"chronology": {
"id":"ISO",
"calendarType":"iso8601"
}
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,我将以下依赖项添加到我的pom:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我没有包含该版本,因为spring boot负责这一点.顺便说一句,我正在使用春季启动1.5.2.RELEASE.
我还在application.properties中包含了以下属性:
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false
Run Code Online (Sandbox Code Playgroud)
知道为什么日期没有格式化,而不是使用我提供的模式?
我无法使用乐观锁定来使用 Spring Data JPA 处理 Spring Boot 2 项目。我有一个测试,在不同的线程中运行 2 个简单的更新,但它们都成功(没有乐观锁异常),并且其中一个更新被另一个更新覆盖。
(请看底部的编辑)
这是我的实体:
@Entity
@Table(name = "User")
public class User {
@Column(name = "UserID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "FirstName")
@NotBlank()
private String fistName;
@Column(name = "LastName")
@NotBlank
private String lastName;
@Column(name = "Email")
@NotBlank
@Email
private String email;
@Version
@Column(name = "Version")
private long version;
// getters & setters
}
Run Code Online (Sandbox Code Playgroud)
这是我的存储库:
public interface UserRepository extends JpaRepository<User, Integer> {
}
Run Code Online (Sandbox Code Playgroud)
这是我的服务:
@Service
public class UserService { …Run Code Online (Sandbox Code Playgroud) 我正在使用primefaces(3.0)调度程序组件.
http://www.primefaces.org/showcase-labs/ui/schedule.jsf
正如我们在这里看到的,有些事件是用蓝色创建的.
现在我想在独特性的基础上改变这些事件的颜色.作为每个雇员的示例,将存在关联的唯一ID.
因此,对于员工ID 1来说,事件颜色将为蓝色,对于ID 2事件,颜色将为红色,依此类推.
如何从支持bean应用这些数量的事件颜色?任何线索....
我能够以这种方式更改调度程序的背景颜色,但是不知道如何更改事件的颜色?
很快,Windows 7将在任何Windows程序(如Paint或WordPad)中使用功能区作为默认界面,从而返回默认工具栏和菜单.
您是否会将UI迁移到使用Windows 7的色带?
我尝试使用Glassfish使用JSF 2的MyFaces impl,但我无法这样做.我在项目中添加了以下jar:
我还将文件glassfish-web.xml添加到WEB-INF,其中包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<property name="useBundledJsf" value="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
Run Code Online (Sandbox Code Playgroud)
编辑
根据BalusC的回答,我删除了myfaces-bundle-2.1.7.jar,现在我得到以下异常:
GRAVE: PWC1305: Exception during cleanup after start failed
org.apache.catalina.LifecycleException: PWC2769: Manager has not yet been started
at org.apache.catalina.session.StandardManager.stop(StandardManager.java:873)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:5571)
at com.sun.enterprise.web.WebModule.stop(WebModule.java:527)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5384)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498) …Run Code Online (Sandbox Code Playgroud) 可能重复:
不使用getter和setter的属性
这是我面临的问题:我正在使用iOS 6.我在头文件中声明了一个属性:
@property (nonatomic) CGFloat scale;
Run Code Online (Sandbox Code Playgroud)
然后在实现中,我创建自己的getter/setter,如下所示:
#define DEFAULT_SCALE 0.90
- (void)setScale:(CGFloat)scale
{
if(_scale != scale) {
_scale = scale;
[self setNeedsDisplay];
}
}
- (CGFloat) scale
{
if(!_scale) {
return DEFAULT_SCALE;
} else {
return _scale;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是编译器无法识别_scale.我得到错误"使用未声明的标识符'_scale'.如果我删除了getter或setter,那么它工作正常,但我不能同时保留两者.如果我这样做,我必须添加@synthesize scale = _scale以避免错误.有人可以解释为什么?
谢谢
java ×4
jsf-2 ×3
jsf ×2
primefaces ×2
spring-boot ×2
ajax ×1
cookies ×1
glassfish ×1
hibernate ×1
html5 ×1
ios ×1
ios6 ×1
jackson ×1
java-8 ×1
javascript ×1
locale ×1
myfaces ×1
objective-c ×1
spring ×1
swing ×1
validation ×1
winforms ×1
wpf ×1