Here's my page:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cpanel="http://java.sun.com/jsf/composite/components/cpanel"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/WEB-INF/templates/cpanelLayout.xhtml">
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="id" value="#{linkDoctorBean.incomingDoctorId}" required="true"/>
<f:event type="preRenderView" listener="#{linkDoctorBean.preRenderView}"/>
</f:metadata>
</ui:define>
<ui:define name="cpanelContent">
<cpanel:adddedClinicDoctor doctor="#{linkDoctorBean.incomingDoctor}" clinic="#{linkDoctorBean.clinic}"/>
<h:form id="form">
<div>
<h:panelGrid columns="2">
<p:selectOneMenu id="doctor"
value="#{linkDoctorBean.doctor}"
converter="#{doctorConverter}"
effect="fade"
var="d"
height="180"
validator="#{linkDoctorBean.validateDoctor}">
<f:selectItem itemLabel="Select a doctor" itemValue="" noSelectionOption="true"/>
<f:selectItems value="#{linkDoctorBean.doctors}" var="doctor" itemLabel="#{stringBean.doctorToString(doctor)}" itemValue="#{doctor}"/>
<p:column>
<p:graphicImage value="#{applicationBean.baseResourceUrl}/doc-photo/small/#{d.urlDisplayName}"/>
</p:column>
<p:column>
#{stringBean.doctorToString(d)}
</p:column>
</p:selectOneMenu>
<p:message id="doctorMessage" for="doctor"/>
</h:panelGrid>
</div>
<div style="margin-top:20px;">
<p:commandButton value="Link" action="#{linkDoctorBean.submit()}" update="doctorMessage" process="@all"/>
<h:link value="Cancel" outcome="/pages/cpanel/manage-doctors" …Run Code Online (Sandbox Code Playgroud) 我正在使用反射来迭代对象的属性.对于Nullable<>类型,使用PropertyType属性正确返回类型.但是,当我调用属性getter时(通过PropertyType.GetGetMethod().Invoke(obj, new object[0])或者PropertyType.GetValue(obj, null),结果的类型是unwrapped原语,不是Nullable<>.为了理由我不想进入,我需要将此结果转换为它的Nullable<>类型.这会抛出InvalidCastException这样的情况:
Convert.ChangeType(property.GetValue(obj, null), property.PropertyType);
Run Code Online (Sandbox Code Playgroud)
还有另一种方法可以确保属性值的类型始终与属性的类型相同吗?
我正在构建我想要从一开始就提升的.NET 3.5应用程序.其目的是配置和控制服务.
我无法在Visual Studio 2010中的任何位置找到可用于以这种方式配置应用程序的任何设置.您认为项目属性中的某个复选框会显示"运行提升",但似乎不存在此类设置.
我创建了一个新的验证器:
package com.example.jsf.validator;
import com.example.components.LoginFormValue;
import com.example.ejb.SecurityEjb;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import javax.inject.Named;
/**
* Validator for {@code login-form} component.
*
* @author steve
*/
@Named
@ApplicationScoped
public class LoginValidator implements Validator, Serializable
{
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
if (value == null)
{
return;
}
LoginFormValue loginFormValue = (LoginFormValue) value;
if (securityEjb.checkCredentials(loginFormValue.getEmailAddress(), loginFormValue.getPassword())) {
return;
}
throw new ValidatorException(new FacesMessage("Incorrect …Run Code Online (Sandbox Code Playgroud) 在AngularJS中,这失败并出现错误:
<my-directive ng-repeat="foo in foos" foo="foo" my-index="{{$index}}"/>
Run Code Online (Sandbox Code Playgroud)
错误信息:
Error: [$parse:syntax] Syntax Error: Token '$index' is unexpected, expecting [:] at column 3 of the expression [{{$index}}] starting at [$index}}].
Run Code Online (Sandbox Code Playgroud)
这是指令:
app.directive('myDirective', function() {
return {
restrict: 'E',
scope: { foo: '=', myIndex: '=' },
templateUrl: 'directives/myDirective.html'
};
});
Run Code Online (Sandbox Code Playgroud)
这似乎只是自定义指令的问题.如果我试试这个:
<div ng-repeat="foo in foos" style="padding: {{$index}}px;">
index == {{$index}}
</div>
Run Code Online (Sandbox Code Playgroud) 这就是我想要生成的:
<div class="marker" style="background:transparent url('/myApp/faces/javax.faces.resource/1.png?ln=images/map') no-repeat center top;"></div>
<div class="marker" style="background:transparent url('/myApp/faces/javax.faces.resource/2.png?ln=images/map') no-repeat center top;"></div>
<div class="marker" style="background:transparent url('/myApp/faces/javax.faces.resource/3.png?ln=images/map') no-repeat center top;"></div>
etc...
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
<ui:repeat value="#{myBean.items}" var="item" varStatus="status">
<h:panelGroup layout="block" styleClass="marker" style="background:transparent url(#{resource['images/map:'+(status.index+1)+'.png']} no-repeat center top;"/>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
这与NumberFormatException失败,因为EL解释器尝试将"images/map"转换为数字.经过相当多的搜索后,我发现+仅用于添加数字.任何想法如何达到预期的效果?
我有一个Java EE 6应用程序,我使用Maven构建,代码在NetBeans 7中,并部署在GlassFish 3.1.2上.当我接近完成时,我发现自己正在部署演示版本.
问题是我没有任何简单的方法来构建不同的环境,如dev,QA,demo,prod等.对于某些东西,我一直在使用带有一堆静态getter返回的Java类基于环境常量值的值.但是这对条件设置没有帮助
可能还有许多我现在都想不到的其他东西分散在XML文件中.
有没有办法定义这些配置文件的多个版本,只需在构建时设置一个标志来选择环境,而在没有指定环境时默认为dev?在这种情况下,有没有办法让Maven为我工作?
我有一个规则可以正常工作:
<rule>
<from>^/(about|account|admin|cpanel)(\?.*)?$</from>
<to last="true">/faces/pages/$1/$1.xhtml$2</to>
</rule>
Run Code Online (Sandbox Code Playgroud)
当我在上面添加以下规则后,javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20在加载与第一个规则匹配的页面时出现异常.
<rule>
<from>^/([^\?]+?)/([^\?]+?)(\?.*)?$</from>
<to last="true">/faces/pages/$1/$2.xhtml$3</to>
</rule>
Run Code Online (Sandbox Code Playgroud)
根据文档,一旦第一个规则匹配,就不应该处理更多规则,因为我指定了last="true".知道我在这里可能缺少什么吗?
我想使用EL将视图ID转换为URL.
这样做的目的是使用html <form/>标签将表单提交到页面GET而不是使用POST.与此不同,表单的action属性需要有一个URL <h:form/>.
此类的实例是大型对象图的一部分,并且不在对象图的根部:
public class Day
{
public Day(LocalDate date, List<LocalTime> times)
{
this.date = date;
this.times = times;
}
public Day()
{
this(null, null);
}
public LocalDate getDate()
{
return date;
}
public List<LocalTime> getTimes()
{
return times;
}
private final LocalDate date;
private final List<LocalTime> times;
}
Run Code Online (Sandbox Code Playgroud)
使用 Jersey 和 JAXB 将对象图转换为 JSON。我已经XmlAdapter注册了LocalDate和LocalTime。
问题是它只对date财产有效,而不是对times财产有效。我怀疑这与列表times而不是单个值有关。那么,我如何告诉 Jersey/JAXBtimes使用注册的来编组列表中的每个元素XmlAdapter?
更新:
通过添加标量属性并观察 JSON 中的预期输出,我确认LocalTime编组确实适用于标量属性。LocalTimeLocalTime
为了完整起见,这里是 …