小编ehs*_*n7b的帖子

ViewParam vs @ManagedProperty(value ="#{param.id}")

定义View Params之间有什么区别:

<f:metadata>
  <f:viewParam name="id" value="#{someBean.id}"/>
</f:metadata>
Run Code Online (Sandbox Code Playgroud)

并在ManagedBean中定义属性,如下所示:

@ManagedProperty(value = "#{param.id}")
private Integer id;
Run Code Online (Sandbox Code Playgroud)

jsf jsf-2 managed-bean viewparams managed-property

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

将国际字符串转换为java中的\ u代码

我如何转换的国际(如俄罗斯)字符串到\u数字(Unicode数字),
\u041e\u041aOK

java unicode escaping unicode-escapes

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

reCaptcha显示"输入错误:无效引用"

我在recaptcha.net上使用mydomain.com注册了一个帐户.

虽然我正在开发我的localhost工作正常,但每当我尝试从本地网络中的另一台机器打开页面时,它会显示"input error: invalid referer"错误消息!

我没有使用recaptcha插件.

php recaptcha

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

非请求范围Bean中的@ManagedProperty(value ="#{param.id}")

我需要将参数(POST)传递给@managedBean,我使用了这样的托管属性:

@ManagedProperty(value = "#{param.id}")
private int id;
Run Code Online (Sandbox Code Playgroud)

Bean的范围是ViewScope

我最终得到了这个错误:

无法创建托管bean收据.发现了以下问题: - 表达式#{param.id},request引用的对象的范围比引用的托管bean范围短

我能做什么?

arjan看看:

我的页面:Facelet Title

<form method="post" action="faces/index.xhtml">
  <input name="id" value="4" />
  <input type="submit" value="submit" />
</form>

<h:form>
  <h:commandLink value="click" action="index">
    <f:param id="id" name="id" value="20"/>
  </h:commandLink>
</h:form>
Run Code Online (Sandbox Code Playgroud)

java jsf managed javabeans jsf-2

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

警告:此页面调用使用前缀[tagname]声明的XML名称空间,但该名称空间不存在taglibrary

我已经将Facelet视图模板声明如下:

<ui:composition template="./templates/master.xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.prime.com.tr/ui">

  <ui:define name="content">
    <h:panelGroup rendered="#{!current.hasLoggedIn()}">      
      <h:panelGroup layout="block" styleClass="warningBox">
        <h:outputText value="#{app.youHaveNotLoggedIn}"/>
        <br/>
        <h:link value="#{lbls.login}" outcome="login"/>
      </h:panelGroup>      
    </h:panelGroup>

    <h:panelGroup rendered="#{current.hasLoggedIn()}">
      <p:panel>
        <f:facet name="header">
          <h:outputText value="#{lbls.requestWaggon}" />
        </f:facet>

        <h:form id="frmRequest">
          <h:panelGrid columns="3" footerClass="buttons">
            <h:outputText value="#{lbls.number}:"/>
            <h:inputText id="number" label="#{lbls.number}" styleClass="ltr" value="#{requestWaggon.request.number}" readonly="true" />
            <h:message for="number" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.requestDate}:"/>
            <h:panelGroup>
              <h:inputText styleClass="date ltr" id="date" label="#{lbls.requestDate}" value="#{requestWaggon.request.date}" required="true">
                <f:converter converterId="ir.khorasancustoms.DateConverter"/>
              </h:inputText>
              <input type="button" value="..." onclick="displayDatePicker('frmRequest:date', this);" class="datePicker"/>
            </h:panelGroup>
            <h:message for="date" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.nameOfMaterialOwner}:"/>
            <h:inputText …
Run Code Online (Sandbox Code Playgroud)

jsf facelets jsf-2

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

Servlet JSP web.xml

我在NetBeans中看到一个用于选择JSPfor a的功能Servlet,结果XML web.xml就是这样的:

<servlet>
    <servlet-name>TestServlet</servlet-name>
    <jsp-file>/index.jsp</jsp-file>
</servlet>
Run Code Online (Sandbox Code Playgroud)

这是什么意思?它的用途是什么?它是否像ASP .NET中的架构背后的代码

java jsp web.xml servlets

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

EJB 3或Hibernate 3

关于Java EE Web应用程序将由完整的Java EE应用程序服务器提供服务,例如GlassFish,这是最好的ORM解决方案?EJB 3Hibernate 3 为什么?

hibernate jpa java-ee ejb-3.0

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

在JOptionPane.showOptionDialog()中设置组件焦点

为了在输入对话框中有自定义按钮标题,我创建了以下代码:

String key = null;
JTextField txtKey = new JTextField();        
int answerKey = JOptionPane.showOptionDialog(this, new Object[] {pleaseEnterTheKey, txtKey}, decryptionKey, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] {okCaption, cancelCaption}, okCaption);        
if (answerKey == JOptionPane.OK_OPTION && txtKey.getText() != null) {
  key = txtKey.getText();
}
Run Code Online (Sandbox Code Playgroud)

如何在显示对话框时将焦点(光标)移动到文本字段?

UPDATE

这对我不起作用,我的意思是文本字段没有焦点:操作系统:Fedora - Gnome

public class Test {
  public static void main(String[] args) {
    String key = null;
    JTextField txtKey = new JTextField();
    txtKey.addAncestorListener(new RequestFocusListener());
    int answerKey = JOptionPane.showOptionDialog(null, new Object[]{"Please enter the key:", txtKey}, "Title", JOptionPane.OK_CANCEL_OPTION, …
Run Code Online (Sandbox Code Playgroud)

java swing focus joptionpane

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

来自ManagedBeans的JSF支持的语言

我已经定义了我支持的语言faces-config.xml如下:

<locale-config>
  <default-locale>fa</default-locale>
  <supported-locale>fa</supported-locale>
  <supported-locale>en</supported-locale>
</locale-config>
Run Code Online (Sandbox Code Playgroud)

如何访问受支持的区域设置ManagedBean?例如,用相应的项填充列表.

jsf localization jsf-2

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

对象为<f:selectItems>中的itemValue

是否可以将对象作为itemValue标记?

例如,我有一个类Foo:

public class Foo {
  private int id;
  private String name;
  private Date date;
}
Run Code Online (Sandbox Code Playgroud)

而另一个班吧

public class Bar {
  private Foo foos;
}

public class BarBean {
  private Set<Foo> foos;
}
Run Code Online (Sandbox Code Playgroud)

现在在一个名为BarBean的Bean中,我需要有一个从用户那里得到当前Bar的Foo,如下所示:

<h:selectOneMenu value="#{barBean.bar.foo}" required="true">
 <f:selectItems value="#{barBean.foos}"  var="foo" itemLabel="#{foo.name}" itemValue="#{foo}" />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)

---------------编辑:

my converter:

package ir.khorasancustoms.g2g.converters;

import ir.khorasancustoms.g2g.persistance.CatalogValue;
import java.util.ResourceBundle;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

@FacesConverter("ir.khorasancustoms.CatalogValueConverter")
public class CatalogValueConverter implements Converter { …
Run Code Online (Sandbox Code Playgroud)

java jsf java-ee jsf-2

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