小编Mar*_*k W的帖子

JSF托管bean和托管属性都是必要的吗?

我是JSF的新手并且想知道:

如果我有一个处理给定页面的所有工作的控制器和一个包含所述页面的所有数据的bean,那么必须同时拥有

@ManagedProperty(value="#{myBean}") 
Run Code Online (Sandbox Code Playgroud)

控制器上的注释和

@ManagedBean(name="myBean")
@SessionScoped
Run Code Online (Sandbox Code Playgroud)

表单bean上的注释?

jsf managed-bean managed-property

7
推荐指数
2
解决办法
2万
查看次数

为什么java.util.calendar对象的值在调用get(int)后会发生变化

我试图调试一些遗留代码中的问题.

我已将问题缩小到以下方法:

public String formatDateTimeFromCalendar (Calendar cal){
        StringBuffer sb = new StringBuffer();
        String hr = ""+cal.get(Calendar.HOUR_OF_DAY);
        sb.append(String.format("%02d", hr)); 
        sb.append(":");
        sb.append(String.format("%02d", cal.get(Calendar.MINUTE)));
        sb.append( " on ");
        sb.append(String.format("%02d", cal.get(Calendar.DAY_OF_MONTH)));
        sb.append( "/");
        sb.append(String.format("%02d", cal.get(Calendar.MONTH)+1));
        sb.append( "/");
        sb.append( cal.get(Calendar.YEAR));
        return sb.toString();
    }
Run Code Online (Sandbox Code Playgroud)

调试第2行cal参数是将来的日期.(2015-01-06T00:00:00.000Z)

与第一线3的执行之后cal.get(calPARAM的值已改变(到2014-12-12T00:00:00.000Z)

为什么/怎么会这样?

以下是创建日历的位置:

Calendar startDateAndTime = Calendar.getInstance();
        startDateAndTime.setTime(response.getStartDate().toGregorianCalendar().getTime());
        startDateAndTime.set(Calendar.HOUR_OF_DAY, response.getStartTime().getHour());
        startDateAndTime.set(Calendar.MINUTE, response.getStartTime().getMinute());
        startDateAndTime.set(Calendar.SECOND, response.getStartTime().getSecond());
        startDateAndTime.set(Calendar.MILLISECOND, response.getStartTime().getMillisecond());
Run Code Online (Sandbox Code Playgroud)

response.getStartDate() 返回一个 XMLGregorianCalendar

java calendar

7
推荐指数
1
解决办法
771
查看次数

刷新SQL Server管理工作室中的表

我在SQL server management studio express中打开了一个表.

我该如何更新?除非我关闭并重新打开表,否则在工作室应用程序之外进行的更改不会显示.当然必须有更好的方法来做到这一点?

sql-server ssms

6
推荐指数
2
解决办法
1万
查看次数

以可重复使用的形式清除复合组件的值

我有一个复合组件:

<ui:component
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">

<cc:interface componentType="compositeLocalDate">
    <cc:attribute name="value" type="org.joda.time.LocalDate" shortDescription="The bean value" required="true" />
    <cc:attribute name="days" type="java.lang.Boolean" shortDescription="Add the days input question" required="true" />
    <cc:attribute name="disabledBy" type="java.lang.Boolean" shortDescription="Disable the component" required="false" />
    <cc:attribute name="limitFuture" type="java.lang.Integer" shortDescription="How many future months to allow based on this number of days in the future. default = all" required="false" />
</cc:interface>

<cc:implementation><!-- 
 --><div class="dateInput">
        <h:inputText autocomplete="off" binding="#{cc.day}" id="day" maxlength="2" styleClass="compositeDay" disabled="#{cc.attrs.disabledBy}" a:placeholder="dd" a:pattern="[0-9]{1,2}" rendered="#{cc.attrs.days}" />

        <h:selectOneMenu binding="#{cc.month}" id="month" styleClass="compositeMonth" disabled="#{cc.attrs.disabledBy}">
            <f:selectItem …
Run Code Online (Sandbox Code Playgroud)

jsf composite-component jsf-2.2

6
推荐指数
0
解决办法
205
查看次数

在运行时动态创建表

是否在运行时基于用户的交互动态创建表格对于Web应用程序来说是好事还是坏事?(我说的是java,但问题可能适用于更多).

database-design web-applications

5
推荐指数
1
解决办法
2885
查看次数

重复的类定义错误

谁能帮忙解决这个问题?

15:02:06,698 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.LinkageError: loader (instance of  org/apache/jasper/servlet/JasperLoader): attempted  duplicate class definition for name: "org/apache/jsp/tag/web/divBox_tag"
Run Code Online (Sandbox Code Playgroud)

[geronimo 2.1,struts 1.2]

java jsp struts java-ee

5
推荐指数
1
解决办法
1万
查看次数

如何在geronimo/tomcat中关闭会话持久性

如何关闭geronimo的会话持久性?这是我应该做的事吗? - 我的应用程序中没有使用持久会话.(这是因为我在控制台中收到了一个不可序列化的错误,但我不希望序列化)

session tomcat geronimo java-ee

4
推荐指数
1
解决办法
3251
查看次数

jquery .serialize()不适用于动态加载的表单

我有一个表单,通过图像点击触发的ajax提交,表单提交后返回并重新加载.但是.serialize()已停止工作.

这是一些代码:

<form id="myForm" action="/someFormSubmitPage.do">
    <div id="myFormQuestions">
        <input type="text" name="fred"/>
        <!--more inputs-->
    </div>
 <img id="submitButton" src="some/path">
</form>
Run Code Online (Sandbox Code Playgroud)

提交按钮的图像通过jquery中的.click触发以下函数

var serializedForm = $("#myForm").serialize();
$.post("/someFormSubmitPage.do", serializedForm, function( data ) {
    //do some stuff with the data
    $( "#myFormQuestions" ).html(data);
});
Run Code Online (Sandbox Code Playgroud)

这在第一次提交时工作正常,但在第二次提交时,尽管用户重新填充输入,但var序列化表单最终仍为空字符串

编辑: 我现在已经包含了一个JSFiddle,但是,我不知道如何使用ajax测试回声的东西.

html javascript jquery

4
推荐指数
1
解决办法
3万
查看次数

阻止Hibernate更新现有记录

我试图让hibernate在每次执行保存时写入新对象而不是更新现有记录.

public class Risk {
    private long riskID;
    private Vehicle vehicle;
}

public class Vehicle {  
    private long vehicleID;
    private long riskID;
    private String regNumber;
    private String abiCode;
    private String make;
    private String model;
}
Run Code Online (Sandbox Code Playgroud)

所以如果把风险写入DB.然后我在网上更换车辆,并尝试再次将风险保存到数据库.我想在风险表中有两个风险,在车辆表中有两个车辆.

目前我正在使用hibernate会话Save(Object o).这总是在数据库中造成新风险,但从未创建新车辆.它只是更新原始的.

这是我的映射文件:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class lazy="false" name="uk.co.test.Risk" schema="quote_engine" table="GV_RISK" >
    <id column="riskID" name="riskID" type="long">
        <generator class="identity"/>
    </id>

    <many-to-one name="vehicle" class="uk.co.test.Vehicle" column="vehicleID" not-null="true" cascade="all" unique="true" />

</class>
Run Code Online (Sandbox Code Playgroud)

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD …
Run Code Online (Sandbox Code Playgroud)

java sql hibernate java-ee

4
推荐指数
1
解决办法
3431
查看次数

java计算的意外结果

为什么以下代码:

System.out.println((int)(19.99 * 100));

产生结果"1998"?

java

4
推荐指数
2
解决办法
209
查看次数