小编Bas*_*sit的帖子

什么是JSF 2.0中的STATE_SAVING_METHOD参数

我无法理解web.xml中这一行的功能是什么

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

我已经读过NetBeans默认是客户端.我刚遇到一个问题,我在我的应用程序中有很多bean,并且<param-value>设置为客户端,所以我得到了

java.io.NotSerializableException

错误,虽然我的bean是Serializable(即他们实现了Serializable接口.).我的豆子在@ViewScope中.但是当我把它改成服务器时,事情就会起作用.为什么?使用客户端和服务器时有什么区别.任何人都可以借助一个例子来解释我.

谢谢

jsf-2

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

如何检查是否处理迭代器中的最后一项?

如果我有一个迭代器并且我想检查最后一个值,我该如何检查它?喜欢

private Set<String> saarcCountries = new TreeSet<String>();
Iterator iter = saarcCountries.iterator();

while(iter.hasNext()) {

    String name = (String)iter.next();
    int countryId = Integer.parseInt(name);

    newsOrAnnouncementInsert.add(newsId);
    newsOrAnnouncementInsert.add(countryId);
    newsOrAnnouncementInsert.add(1);            //addby

    if (!(last value in iterator))) {
        newsOrAnnouncementInsert.add("~!~");//Delimiter for Multiple Detail Records
    }//end if

} //end of while
Run Code Online (Sandbox Code Playgroud)

我该如何检查最后一个值.什么应该替换迭代器中的最后一个值

java iterator

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

如何防止用户在达到最大字符限制后在textarea中输入文本

我想阻止用户在达到最大字符限制时在textarea中输入文本.发生了什么,当我达到最大限制然后我的文本区域滚动条移动到顶部我以某种方式阻止这个代码.

jQuery(document).ready(function($) {
    $('textarea.max').keyup(function() {
        var $textarea = $(this);
        var max = 400;
        if ($textarea.val().length > max) {
            var top = $textarea.scrollTop();
            $textarea.val($textarea.val().substr(0, max));
            $textarea.scrollTop(top);

        }
    });
}); //end if ready(fn)
Run Code Online (Sandbox Code Playgroud)

但我也希望在达到最大限制后用户无法在textarea中输入任何内容.目前发生的情况是,如果用户按住键,达到最大限制后,字符在文本区域中键入,虽然在释放按钮后它返回到原始文本(即$ textarea.val($ textarea.val()). substr(0,max));).但是,一旦这种情况成为现实,我希望这样

if ($textarea.val().length > max) {
Run Code Online (Sandbox Code Playgroud)

用户无法输入任何内容.我希望光标从textarea中消失.但是如果用户删除了一些文本,那么光标也可供用户再次输入输入.我该怎么做?

jquery

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

如何读取消息并将参数传递给JSF 2.0中的message.properties文件

假设我有一个messages.properties文件

windowTitle=Accessing Form Elements with JavaScript
namePrompt=Name:
passwordPrompt=Password:
confirmPasswordPrompt=Confirm Password:
Run Code Online (Sandbox Code Playgroud)

我在faces-config.xml中有这样的条目

<faces-config version="2.0"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

    <application>
        <resource-bundle>
            <base-name>pk.mazars.basitMahmood.messages</base-name>
            <var>msgs</var>
        </resource-bundle>
    </application>

</faces-config>
Run Code Online (Sandbox Code Playgroud)

在我的xhtml页面上,我可以像这样访问它

<h:panelGrid columns="2" columnClasses="evenColumns, oddColumns">
    #{msgs.namePrompt}
    <h:inputText/>
    #{msgs.passwordPrompt}
    <h:inputSecret id="password"/>
    #{msgs.confirmPasswordPrompt}
    <h:inputSecret id="passwordConfirm"/>
</h:panelGrid>
Run Code Online (Sandbox Code Playgroud)

但是如何从Java中读取此文件.比如,假设我必须打印这样的消息,或者提示用户必须输入名称

System.out.println(msgs.namePrompt + "must be entered")
Run Code Online (Sandbox Code Playgroud)

如何从我的java代码中读取msgs.namePrompt值.

还假设我的消息文件中有这样的条目

sure=Are you sure, you want to delete the <Field>?
remove=Are you sure you want to remove the<Field> and <Field>?
close=Are you sure you want to mark the <Field> as Closed?
created=<Field> is successfully …
Run Code Online (Sandbox Code Playgroud)

jsf-2

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

如何在JSF 2.0中使用jQuery

我正在学习jQuery.我想在我的jsf 2.0应用程序中使用jQuery.就像我有html文件,我在这里使用jQuery

<head>
    <title>The Devil's Dictionary</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="css/06.css" type="text/css" />

    <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="js/06.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)

我只是从jQuery官方网站下载了jquery-1.7.1.js文件,将其包含在我的目录中,然后开始使用jQuery.

我的06.js文件conatin代码是这样的

$(document).ready(function() {

    $('#letter-a a').click(function(){

        /**
         * The .load() method does all our heavy lifting for us! We specify the target location for
         * the HTML snippet by using a normal jQuery selector, and then pass the URL of the file to
         * be loaded as a parameter to the method. Now, when the first link …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-plugins jsf-2

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

获取错误无法在类上找到适当的构造函数

我试图将本机SQL结果映射到我的POJO.这是配置.我在用春天.

<bean id="ls360Emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
    <property name="dataSource" ref="ls360DataSource" />
    <property name="jpaVendorAdapter" ref="vendorAdaptor" />         
    <property name="packagesToScan" value="abc.xyz"/>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.max_fetch_depth">3</prop>
            <prop key="hibernate.jdbc.fetch_size">50</prop>
            <prop key="hibernate.jdbc.batch_size">10</prop>
            <prop key="hibernate.show_sql">true</prop>              
        </props>        
    </property>
</bean> 
Run Code Online (Sandbox Code Playgroud)

这是我的班级

@SqlResultSetMapping(
    name="courseCompletionMapping", 
    classes = {
        @ConstructorResult(targetClass = CourseCompletion.class,
            columns={
                @ColumnResult(name = "StoreId", type = String.class),
                @ColumnResult(name = "ProductId", type = String.class),
                @ColumnResult(name = "UserName", type = String.class),
                @ColumnResult(name = "Score", type = Integer.class),
                @ColumnResult(name = "CompletionDate", type = Date.class)
             }
        )
    }
) 
@Entity
public class CourseCompletion …
Run Code Online (Sandbox Code Playgroud)

spring-data-jpa hibernate-4.x jpa-2.1

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

getResourceAsStream()返回null.属性文件未加载

我正在尝试加载属性文件.这是我的结构

目录结构

现在我正在尝试加载test.properties文件.但是我变得无效了.我在这里怎么样

public class Test {

    String workingDir = System.getProperty("user.dir");
    System.out.println("Current working directory : " + workingDir);

    File temp = new File(workingDir + "\\" + "test.properties");
    String absolutePath = temp.getAbsolutePath();
    System.out.println("File path : " + absolutePath);

    Properties properties = null;

    try {
        properties = new Properties();
        InputStream resourceAsStream =  Test.class.getClassLoader().getResourceAsStream(absolutePath);
        if (resourceAsStream != null) {
            properties.load(resourceAsStream);
        }


    } catch (IOException e) {
        e.printStackTrace();
    }

    System.exit(0);

} //end of class Test
Run Code Online (Sandbox Code Playgroud)

这个程序打印

Current working directory : D:\Personal Work\eclipse 32 Bit\workspace\Spring Integration\LS360BatchImportIntegration …
Run Code Online (Sandbox Code Playgroud)

java

20
推荐指数
3
解决办法
6万
查看次数

如何在一个css选择器中访问两个ID

我有div有三个按钮,

<div id="buttons">
    <input id="preview" class="ButtonStyle" type="submit" value="Preview" name="preview">
    <input id="add" class="ButtonStyle" type="submit" value="Save" name="add">
    <input id="Cancel" class="ButtonStyle" type="submit" value="Cancel" name="Cancel">
</div>
Run Code Online (Sandbox Code Playgroud)

我设定了它的风格.我想要添加和取消按钮都有左边距:5px; 现在我这样做,

#outboxmidpg #buttons input[type="submit"]{
    font-weight: bold;
    width: 70px;
}

#outboxmidpg #buttons input[id="Cancel"] {
    margin-left: 5px;
}

#outboxmidpg #buttons input[id="add"] {
    margin-left: 5px;
}
Run Code Online (Sandbox Code Playgroud)

我想在一行中做到这一点.我试过这个,但它没有用,它也删除了取消按钮边距.

#outboxmidpg #buttons input[id="Cancel"] input[id="add"] {
    margin-left: 5px;
}
Run Code Online (Sandbox Code Playgroud)

无论如何,我能在一条线上实现这种风格吗?

谢谢

css

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

获取错误没有定义类型[javax.persistence.EntityManagerFactory]的限定bean:期望的单个匹配bean但找到2

我是春天的3.2.这是我的配置文件

 <bean id="legacyDataSource" name="legacydb" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
    <property name="driverClassName" value="${jdbc.legacy.driverClassName}" />
    <property name="url" value="${jdbc.legacy.url}" />  
    <property name="username" value="${jdbc.legacy.username}" />
    <property name="password" value="${jdbc.legacy.password}" />
</bean>

 <bean id="ls360DataSource" name="Ls360db" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true" >
    <property name="driverClassName" value="${jdbc.ls360.driverClassName}" />
    <property name="url" value="${jdbc.ls360.url}" />  
    <property name="username" value="${jdbc.ls360.username}" />
    <property name="password" value="${jdbc.ls360.password}" />
</bean>

<bean id="legacyTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="legacyEmf"/>
</bean>

<bean id="ls360TransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="ls360Emf"/>
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="legacyEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
    <property name="dataSource" ref="legacyDataSource" />
    <property name="jpaVendorAdapter" ref="vendorAdaptor" />         
    <property name="packagesToScan" value="com.softech.ls360.integration.regulators.plcb.domain"/>
    <property name="jpaProperties"> …
Run Code Online (Sandbox Code Playgroud)

spring jpa-2.0 spring-data-jpa

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

如何在使用ui:composition时更改页面的头元素

我想问一个问题,我有一个像这样的主模板

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <title>Login</title>
    </h:head>

    <h:body>
        <div id="top">
            <ui:insert name="top">
                <ui:include src="header.xhtml" id="header"/>
            </ui:insert>
        </div>
        <div>
            <div id="content">
                <ui:insert name="content"></ui:insert>
            </div>
        </div>
        <div id="bottom" style="position: absolute;top: 675px;width: 100%" align="center">
            <ui:insert name="bottom">
                <ui:include src="footer.xhtml" id="footer"/>
            </ui:insert>
        </div>
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

在我的每一页上我都使用这样的东西

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>City Setup</title>
    </h:head>

    <h:body>
        <ui:composition …
Run Code Online (Sandbox Code Playgroud)

facelets templating jsf-2

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