小编gaf*_*fcz的帖子

从java bean重定向的JSF页面

有没有办法如何从Java方法页面重定向到其他页面?

我只能使用以下方式转发它:

FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
Run Code Online (Sandbox Code Playgroud)

或使用导航规则faces-config.xml.

你有什么想法?

jsf redirect managed-bean

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

将favicon添加到JSF项目并在<link>中引用它

如何将一个favicon添加到JSF项目并在<link>元素中引用它?

我试过如下:

<h:head>
    <link rel="icon" type="image/x-icon" href="images/favicon.ico"/>
    ...
</h:head>
Run Code Online (Sandbox Code Playgroud)

但是,它没有显示任何图标.

html favicon jsf

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

NET START <SERVICE> - 获取服务名称的方式/位置?

我需要创建一个通用脚本来重启服务:

net stop <service>
net start <service>
Run Code Online (Sandbox Code Playgroud)

问题是我不知道服务的名称.例如," printer spooler"是名称" spooler".

如何找到任何服务的名称?

windows service windows-services

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

HttpSession - 如何获取session.setAttribute?

我正在以这种方式创建HttpSession容器:

@SessionScoped
@ManagedBean(name="userManager")
public class UserManager extends Tools
{
  /* [private variables] */
  ...
  public String login() 
  {
    /* [find user] */
    ...
    FacesContext context = FacesContext.getCurrentInstance();
    session = (HttpSession) context.getExternalContext().getSession(true);
    session.setAttribute("id", user.getID());
    session.setAttribute("username", user.getName());
    ...
    System.out.println("Session id: " + session.getId());
Run Code Online (Sandbox Code Playgroud)

我有SessionListener,它应该给我关于创建的会话的信息:

@WebListener
public class SessionListener implements HttpSessionListener
{
  @Override
  public void sessionCreated(HttpSessionEvent event) {    
    HttpSession session = event.getSession();
    System.out.println("Session id: " + session.getId());
    System.out.println("New session: " + session.isNew());
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得该username属性?

如果我正在尝试使用System.out.println("User name: " + …

java jsf listener java-ee

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

提交表单后,在输入中重新显示损坏的字符

我通常可以写捷克字符串到表单:

在此输入图像描述

但是在验证之后(以及当我将收集的字符串发送到数据库时)字符串在其他一些字符集中:

在此输入图像描述

h:outputTexts(jméno,příjmení)仍然正常显示,h:inputTexts不是.

我应该在哪里寻找问题?

更新: HTTP响应标头:

在此输入图像描述

解:

  • request.setCharacterEncoding("UTF-8")in 创建过滤器Filter#doFilter()
  • 检查所有xml以配置UTF-8
  • 添加<f:view contentType="text/html" encoding="UTF-8"/>到主xhtml
  • 将这些行添加到hibernate.cfg.xml:

    <property name="hibernate.connection.characterEncoding">utf8</property>

    <property name="hibernate.connection.useUnicode">true</property>

jsf utf-8 character-encoding

8
推荐指数
1
解决办法
8368
查看次数

将RICHFACES添加到现有的JSF2项目中

我正在尝试使用这个jboss指南为我的JSF 2项目添加richfaces .我已经完成了他们在第2.6点中所说的内容,但在重新启动我的tomcat服务器之后,会报告HTTP状态404.

我错过了什么吗?

更新: 当我添加richfaces-components-ui-4.0.0.Final.jar和richfaces-core-impl-4.0.0.Final.jar,并重新启动tomcat服务器时,它会报告:

INFO: Unsanitized stacktrace from failed start...
com.sun.faces.config.ConfigurationException: 
Source Document: jar:file:/D:/WORKSPACE/BC/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PORTAL/WEB-INF/lib/richfaces-core-impl-4.0.0.Final.jar!/META-INF/faces-config.xml
Cause: Unable to create a new instance of 'org.richfaces.resource.ResourceHandlerImpl': java.lang.reflect.InvocationTargetException
at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:293)
....

13.5.2011 8:41:52 com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment: 
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! com.google.common.base.Function
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:379)
....

13.5.2011 8:41:52 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! com.google.common.base.Function
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
....
13.5.2011 8:41:52 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
13.5.2011 8:41:52 …
Run Code Online (Sandbox Code Playgroud)

jsf richfaces jsf-2

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

<h:inputText>启用/禁用 - 更改背景颜色

我可以更改禁用的背景颜色<h:inputText>吗?

我试过这样做:

<h:inputText value="test" disabled="true" styleClass="input"/>
Run Code Online (Sandbox Code Playgroud)

css包含:

input:disabled {background-color:blue;}
input:enabled {background-color:red;}
Run Code Online (Sandbox Code Playgroud)

结果是:

在此输入图像描述

原因,为什么我要改变背景是,因为我已经安装了richfaces,禁用和启用了相同的颜色,都是白色的

谢谢

更新:

在此输入图像描述

HTML:

<td class="width10">Sm?na:</td>
<td class="width15"><input name="bde:j_idt100" value="2011-05-18-S2" size="13" style="background-color: blue; color: red;" disabled="disabled" type="text"><input id="bde:shift" name="bde:shift" type="hidden"></td>
<td><input name="bde:j_idt102" value="ranní" class="input2" size="13" disabled="disabled" type="text"><input name="bde:j_idt103" value="admin" class="input2" size="13" disabled="disabled" type="text"></td>
</tr>
<tr class="rowEven">
<td class="width5"><input id="bde:f1" name="bde:f1" value="F1" tabindex="2" title="Novy pracovnik - vymaze vsechna pole formulare" class="btninput" type="submit"></td>
<td class="width10">Pracovník:</td>
<td class="width15">
<input id="bde:worker" name="bde:worker" class="input" size="13" tabindex="1" onblur="jsf.util.chain(this,event,'mojarra.ab(this,event,\'blur\',\'@this\',\'bde:inputName\')','mojarra.ab(this,event,\'blur\',\'@this\',\'bde:inputSname\')','mojarra.ab(this,event,\'blur\',\'@this\',\'bde:inputDep\')','mojarra.ab(this,event,\'blur\',\'@this\',\'bde:reportErr\')')" type="text"></td>
Run Code Online (Sandbox Code Playgroud)

richfaces之间的图形差异生成代码和HTML:

在此输入图像描述在此输入图像描述

html css java jsf richfaces

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

JAVA - 将CSV导入ArrayList

我正在尝试使用导入CSV文件:ArraylistStringTokenizer

public class Test
{
  public static void main(String [] args)
  {
    List<ImportedXls> datalist = new ArrayList<ImportedXls>();

    try
    {
      FileReader fr = new FileReader("c:\\temp.csv");
      BufferedReader br = new BufferedReader(fr);
      String stringRead = br.readLine();

      while( stringRead != null )
      {
        StringTokenizer st = new StringTokenizer(stringRead, ",");
        String docNumber = st.nextToken( );
        String note = st.nextToken( );  /** PROBLEM */
        String index = st.nextToken( ); /** PROBLEM */

        ImportedXls temp = new ImportedXls(docNumber, note, index);
        datalist.add(temp);

        // read …
Run Code Online (Sandbox Code Playgroud)

java csv import arraylist

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

在ajax调用<f:ajax>之后处理onclick函数

在提交表单(ajax调用)后,我正在尝试选择并专注于选择组件ID.

<script>
var myFunc = function() {
  document.getElementById('form:#{bean.componentId}').focus();
  document.getElementById('form:#{bean.componentId}').select();
};

$(document).ready(function() {
  myFunc();
});
</script>

<h:form id="form">
  <h:commandButton action="#{bean.save}" onclick="return myFunc();" ...>
    <f:ajax execute="@form" render="@form"/>
  </h:commandButton>
  ...
</h:form>
Run Code Online (Sandbox Code Playgroud)

这个解决方案正在运行,但问题是,<f:ajax>称为AFTER onclick,因此在选择组件后渲染表单,并清除焦点.

如何在表单呈现后调用我的函数?

更新:(我试过例子)

  • 添加onevent="myFunc();"f:ajax=>会导致刷新页面
  • 添加onevent="myFunc()"f:ajax=>相同的行为onclick属性
  • 接下来f:ajaxoneventattr.=>仍然一样

update2(它应该如何工作):

  • 提交按钮是ajax调用
  • 表格根据需要进行清洁
  • 适当的领域是集中的(取决于一些用户选择的因素)

ajax jsf jsf-2

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

MS SQL - 查找和删除重复项

可能重复:
SQL - 如何删除重复的行?
SQL查询从同一个表中删除重复的行?

如何在此表中找到双重性?

在此输入图像描述

A是唯一ID,列EF不相关,因此行1,2,3和行4,5是重复的

sql sql-server

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