我想用 Mojarra 2.1
http://javaserverfaces.java.net/download.html
我的容器是Tomcat 7,我正在使用IceFaces 2.
我应该只包括如下API吗?
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
更新:我正在使用servlet 3.0.1,jsp 2.2.1,el 2.2也许它是冲突的:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.2</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我想禁用单击按钮几秒钟,并在此期间显示图像,然后隐藏图像并再次显示按钮。
HTML:
<input type="submit" value="Submit" onclick="validate();" name="myButton" id="myButton">
<img style="display: none;" src="/images/loading.gif" id="myImage">
Run Code Online (Sandbox Code Playgroud)
JavaScript:
function validate(){
var myButton= document.getElementById('myButton');
var myImage= document.getElementById('myImage');
setTimeout (function(){
myButton.style.display ='none';
},5000);
setTimeout (function(){
myImage.style.display ='inline';
},5000);
}
Run Code Online (Sandbox Code Playgroud)
问题:
这个js代码不是在onclick上执行的,而是在这个按钮的action被调用之后(使用JSF 2)
调用此代码时,按钮会隐藏并显示图像,但不会再次隐藏,按钮也不会再次显示。
请建议如何解决这个问题。
我有一个格式化的PDF文件,我想在jsf页面中显示它(具有相同的格式)并能够打印它.
请告知如何实现这一目标.
问候所有我想在表中插入70条记录,值为value1,value2,... value70,我想知道是否可以通过SQL查询来实现这一点我使用的是postgresql db.提前致谢.
我在表格中收到了一些电子邮件:
staticN123@sub1.mydomain.com
staticN456@sub2.mydomain.com
staticN789@sub3-sub.mydomain.com
Run Code Online (Sandbox Code Playgroud)
动态是(N或M或F)字符后面的数字,以及@和mydomain.com之间的子域名
我想在字符串中创建一个与此表单匹配的正则表达式,如果匹配,则获取N字符后面的数字.
我在MySQL数据库中有两个表:
1-活动:
2-内容:
我有一个名为CampaignData的java bean(不是hibernate实体)
public class CampaignData {
private long contentId;
private long contentSubTypeId;
private Long distributionGroupId;
}
Run Code Online (Sandbox Code Playgroud)
这是我如何进行查询:
CampaignData campaignData = (CampaignData) session
.createSQLQuery(
"select camp.fk_Content as contentId,camp.tk_DistributionGroup as distributionGroupId,cont.tk_contentSubtype as contentSubTypeId "
+ "from campaign camp,content cont"
+ " where camp.pkid=:campaignId and camp.fk_Content=cont.pkid")
.setLong("campaignId", campaignId)
.setResultTransformer(
Transformers.aliasToBean(CampaignData.class))
.uniqueResult();
Run Code Online (Sandbox Code Playgroud)
它产生hibernate查询:
select
camp.fk_Content as contentId,
camp.tk_DistributionGroup as distributionGroupId,
cont.tk_contentSubtype as contentSubTypeId
from
campaign camp,
content cont
where
camp.pkid=?
and …Run Code Online (Sandbox Code Playgroud) 我有两个单选按钮,默认情况下没有选中任何一个,并且必须选择其中一个,所以这就是我所做的:
<div id="payment_method">
<h:message for="sel_payment_method" style="Color:red;"/>
<h:selectOneRadio id="sel_payment_method" required="true" requiredMessage="Please select a payment method" value="#{myBean.selectedPaymentMethod}">
<f:selectItem itemLabel="Debit or Credit Card" itemValue="credit" />
<f:selectItem itemLabel="Checking Account" itemValue="checking" />
<f:ajax event="change" render="credit_inputs_fragment checking_inputs_fragements" />
</h:selectOneRadio>
</div>
Run Code Online (Sandbox Code Playgroud)
该selectedPaymentMethod属性是一个字符串,其默认值为null
而credit_inputs_fragment是一个包含div的ui:fragement
问题:点击单选按钮时,要更改的两个片段不受影响.
请指教,谢谢.
我有一个junit测试用例,它运行如下代码:
if (SecurityUtil.isAuthenticated()) {
}
Run Code Online (Sandbox Code Playgroud)
它给出了一个例外:
org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.
Run Code Online (Sandbox Code Playgroud)
我的测试类配置如下:
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({ WebContextTestExecutionListener.class,
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class })
@ActiveProfiles("test")
@DirtiesContext
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = {
SpringConfig.class, SpringTestingConfig.class,
SpringLocalContainerJPAConfig.class, CustomConfiguration.class })
public class MyTestClass { }
Run Code Online (Sandbox Code Playgroud)
请告知如何修复此错误,谢谢.
我正在使用 mockito 并且我有一个自定义日期类,我希望能够在我的测试类中模拟这个日期类,所以我尝试了以下操作:
MVDate date = Mockito.mock(MYDate.class);
Mockito.when(date.get(Calendar.MONTH)).thenReturn(5);
Run Code Online (Sandbox Code Playgroud)
MYDate 类:
public class MYDate extends GregorianCalendar implements Comparable<Calendar> {
public MYDate() {
setTime(new Date());
}
}
Run Code Online (Sandbox Code Playgroud)
但是在尝试打印时new MYDate();它总是打印当前日期。请告知我应该如何模拟日历类,以便我可以在特定日期测试所有创建新数据实例的方法。
嗨伙计们,我试图禁止输入密钥在textarea中提交表单
使用以下功能:
function noenter() {
return !(window.event && window.event.keyCode == 13);
}
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<form:form modelAttribute="myObject" method="post" action="${myUrl}">
<form:textarea path="name" class="new_obj submits_on_return" cols="40" rows="3" onkeypress="return noenter()"></form:textarea>
Run Code Online (Sandbox Code Playgroud)
但它根本不起作用,总是提交,任何想法为什么?
我的情况是,我有一个采用 Collection 的方法,当我尝试将列表值添加到集合参数中时,我将该值作为列表,但它不起作用,所以我应该转换它吗?
更新: 当我尝试创建时:
new org.springframework.security.core.userdetails.User(
user.getEmail(), user.getPassword(), true, true, true, true,
user.getAuthorities());
Run Code Online (Sandbox Code Playgroud)
其中 user.getAuthorities() 返回我定义的 Authority 对象的数组列表
上面的代码给出了构造函数未定义的错误,当我添加集合转换时它工作正常。
org.springframework.security.core.userdetails
类用户构造函数
User(java.lang.String username, java.lang.String password,
boolean enabled, boolean accountNonExpired,
boolean credentialsNonExpired, boolean accountNonLocked,
java.util.Collection<? extends GrantedAuthority> authorities)
Run Code Online (Sandbox Code Playgroud) java ×4
jsf-2 ×4
java-ee ×2
javascript ×2
jsf ×2
junit ×2
el ×1
forms ×1
hibernate ×1
html ×1
maven ×1
mocking ×1
mockito ×1
mysql ×1
postgresql ×1
primefaces ×1
regex ×1
shiro ×1
spring ×1
spring-mvc ×1
sql ×1
unit-testing ×1