相关疑难解决方法(0)

PrimeFaces DataTable CellEdit获取实体/对象

我有一个数据表,它显示基于List <>的各种实体.当我选择一个单元格进行编辑时,我希望能够以某种方式获取实体以便更新它.当然有event.getRowIndex,然后我可以使用List <>,但这并不总是方便的.是否有另一种方法可以从CellEditEvent获取实体?

jsf facelets primefaces

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

如何在valueChangeListener方法中获取更新的模型值?

我在valueChangeListener上遇到了问题.我在Weblogic 6.0上使用JSF 1.2.

我有一个页面,页面顶部有2个单选按钮,名称为Name1和Name2.单击Name1时,单选按钮下方将显示Name1详细信息(大约30个字段),单击Name2时,将显示Name2详细信息.现在,用户可以更新单击的命名详细信息.例如,用户单击Name1并更改地址字段,然后单击Name2并更改Name2的年龄.当用户单击Name1时,地址应显示为使用新值更新,并且当用户单击Name2时,应再次更新年龄.

我使用valueChangeListener来解决它,因为我需要更改事件的旧值和新值.问题是,当在VALIDATION阶段结束时调用valueChangeListener时,我没有在valueChangeListener方法中获取Name1字段的更新地址.有人可以帮我解决问题吗?

jsf valuechangelistener

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

primefaces部分处理不起作用

我想使用部分处理但它在我的代码中不起作用.有人知道为什么吗?

<h:form id="frmVehicle" prependId="false">
   <p:toolbar styleClass="form_toolbar">   
      <p:toolbarGroup>
        <p:commandButton id="save" process="@(form :not(.noprocess))" ajax="false" value="#{uimsgs.save}" action="#{vmsVehicleActionBean.save()}"
      </p:toolbarGroup>
    </p:toolbar>
    <p:messages id="vmsgs" severity="error,warn" autoUpdate="true" />
    <p:tabView id="tabViewSections" orientation="left" styleClass="ses-ui-tabs-left">
      <p:tab title="#{vms_uimsgs['vehicle.tab.data']}">
        <p:panelGrid id="gridHeader" columns="4" columnClasses="form-label,form-input,form-label,form-input" styleClass="form-grid" >
           <p:outputLabel for="kmStatus" value="#{vms_uimsgs['vehicle.kmStatus']}" />
           <p:inputText id="kmStatus" value="#{vmsVehicleActionBean.vehicle.kmStatus}"/>
           <p:outputLabel for="powerKw" value="#{vms_uimsgs['vehicle.power']}" />
           <p:inputText id="powerKw" styleclass="noprocess" value="#{vmsVehicleActionBean.powerKw}">
              <p:ajax event="keyup" update="powerPs" />
           </p:inputText>
           <p:outputLabel value="kw" />
           <p:inputText id="powerPs" styleclass="noprocess" value="#{vmsVehicleActionBean.powerPs}"> 
             <p:ajax event="keyup" update="powerKw" />
           </p:inputText>
           <p:outputLabel value="ps" />
         </p:panelGrid>
       </p:tab>
     </p:tabView>
 </h:form>
Run Code Online (Sandbox Code Playgroud)

两个setter(kw&ps)仍在处理中.任何的想法?

java jquery jsf primefaces

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

JSF在action,actionlistener,onClick之间的区别

我在我的项目中使用JSF.我正在使用PrimeFaces的上下文菜单.我看到p:menuItem我们有action,actionListener,onclick方法.所以我的问题是:什么时候我都用action,actionListner,onclick,什么是执行的顺序?

jsf primefaces jsf-2

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

Valuechangelistener在JSF中存在疑问

HI,

请参阅以下代码:

                <h:selectOneMenu id="countries" value="#{countryBean.selectedCountry}" onchange="submit()
                                    valueChangeListener="#{countryBean.changeCountry}">
                    <f:selectItems value="#{countryBean.countries }" />
                </h:selectOneMenu>  
Run Code Online (Sandbox Code Playgroud)

支持Bean

public void changeCountry(ValueChangeEvent event){      
    String newValue = (String)event.getNewValue();
    String oldValue = (String)event.getOldValue();

    System.out.println("New Value : " + newValue);
    System.out.println("Old Value : " + oldValue);

    if ("1".equals(newValue)){
        this.countries = new ArrayList<SelectItem>();
        this.cities.add(new SelectItem("1","Delhi"));
        this.cities.add(new SelectItem("2","Mumbai"));
    }
    if ("2".equals(newValue)){
        this.cities = new ArrayList<SelectItem>();
        this.cities.add(new SelectItem("1","Mossco"));
    }       
}
Run Code Online (Sandbox Code Playgroud)

如果实施正确,请告诉我.它工作正常.我的问题是:

  • h:selectOneMenu标记内添加f:valueChangeListener标记有什么好处.我使用了普通属性valueChangeListener ="#{countryBean.changeCountry}".
  • 是否有必要使用onchange ="submit()此代码来更改值.
  • 通过实现ActionListener接口并仅使用UIComponent标记中的属性(action ="methodName")来编写自定义侦听器之间有什么区别.请解释一下.

jsf

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

JSF中具有单个命令组件的多个动作侦听器

是否可以使用单个命令组件调用多个侦听器方法?例如,

视图范围的bean:

@ManagedBean
@ViewScoped
public final class ViewScopedBean implements Serializable
{
    @ManagedProperty(value = "#{sessionScopedBean}")
    private SessionScopedBean sessionScopedBean; //Getter/Setter.
    private static final long serialVersionUID = 1L;

    public ViewScopedBean() {}

    public void action()
    {
        //Do something.
        sessionScopedBean.action();
    }
}
Run Code Online (Sandbox Code Playgroud)

会话范围的bean:

@ManagedBean
@SessionScoped
public final class SessionScopedBean implements Serializable
{
    private static final long serialVersionUID = 1L;

    public SessionScopedBean () {}

    public void action() {
        //Do something.
    }
}
Run Code Online (Sandbox Code Playgroud)

一个命令按钮,如下所示,

<h:commandButton value="Action" actionListener="#{viewScopedBean.action}"/>
Run Code Online (Sandbox Code Playgroud)

调用该方法action(),ViewScopedBean然后通过注入该bean的实例来调用该action()方法SessionScopedBean.

是否有可能在XHTML上做同样的事情,以便可以消除只是为了调用方法而注入bean的需要?

jsf jsf-2

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

JSF ajax请求中的异常处理

在处理JSF ajax请求时抛出异常时,如何处理异常并访问堆栈跟踪?现在,当JSF项目阶段设置为Development时,我只在JavaScript警报中获取异常类名称和消息.更糟糕的是,当JSF项目阶段设置为Production时,没有任何视觉反馈,并且服务器日志不显示有关异常的任何信息.

如果这是相关的,我在Netbeans中使用GlassFish.

ajax jsf exception-handling jsf-2.2

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

JSF中的多个actionlisteners

我想在进一步处理之前使用多个动作侦听器来设置两个支持bean的状态

第一种方式:

<p:commandButton process="@this" >
   <f:attribute name="key" value="#{node.getIdTestGroup()}" />
   <f:actionListener binding="#{testController.nodeListener}" />
<f:actionListener binding="#{testDeviceGroupController.prepareCreate}" />
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)

它给出了一个例外:

警告:/ testGroup/List.xhtml @ 26,88 binding ="#{testController.nodeListener()}":找不到方法nodeListener javax.el.E​​LException:/testGroup/List.xhtml @ 26,88 binding ="#{ testController.nodeListener()}":找不到方法nodeListener

第二种方式:

<p:commandButton process="@this" >
    <f:attribute name="key" value="#{node.getIdTestGroup()}" />
    <f:actionListener binding="#{testController.nodeListener(event)}" />
    <f:actionListener binding="#{testDeviceGroupController.prepareCreate(event)}" />
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)

nodeListener和prepareCreate方法的事件为null

怎么做对吗?

jsf primefaces jsf-2

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

&lt;f:setPropertyActionListener&gt;父级不是ActionSource类型,类型是:com.sun.faces.component.PassthroughElement

我在JSF项目中使用Passthrough元素,并且需要执行以下操作:

<h:commandLink action="#{myBean.acao()}" value="click me">
        <f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)

但是使用Passthrough元素可以更好地控制前端,例如尝试以下操作:

<a href="#" jsf:action="#{myBean.acao()}">click me
        <f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</a>
Run Code Online (Sandbox Code Playgroud)

但显然这不起作用,我收到以下错误消息:

<f:setPropertyActionListener> Parent is not of type ActionSource, type is: com.sun.faces.component.PassthroughElement
Run Code Online (Sandbox Code Playgroud)

有谁知道我该怎么解决?

jsf jsf-2.2 passthrough-elements setpropertyactionlistener

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

使用javascript参数对ajax回调进行Primeface

我正在努力将Primefaces bean属性直接发送到javascript,以便打开一个新页面并将bean属性的内容写入新页面.

我正在使用Primefaces 4.0.

我有一个这样的命令按钮:

 <p:commandButton id="buttonId" update="buttonId, otherComponentId"
    value="press me" process="@this" actionListener="#{homeController.myMethod}"
    oncomplete="handleComplete(xhr, status, args)">
 </p:commandButton>
Run Code Online (Sandbox Code Playgroud)

在handleComplete中,javascript函数args未定义,但不是xhr和status.javascript函数定义:

function handleComplete(xhr, status, args){
    var w = window.open();
    w.document.open();
    alert(xhr.responseText.substring(100));
    alert(status);
    alert(args);
    var d = '<head></head><body>'+ args.firstParam +'<body>';
    w.document.write(d);
    w.document.close();
}
Run Code Online (Sandbox Code Playgroud)

首先警告它给我页面,第二个解析错误,错误是:Uncaught TypeError:无法读取未定义的属性'firstParam'

我想在args中传入一个这样的字符串:

public String MyMethod() {
    RequestContext context = RequestContext.getCurrentInstance();  
    context.addCallbackParam("firstParam", "my string");
      return "";
}
Run Code Online (Sandbox Code Playgroud)

并使用javascript访问它args.firstParam.

该方法被调用,(我有一些工作的打印屏幕.)

我必须尝试这种方式,而不是将文本设置为

<h:outputText id="myText" escape="false" rendered="true"
            value="#{homeController.property}" />
Run Code Online (Sandbox Code Playgroud)

然后得到这个元素的innerHTML,因为我将使用innerHTML获得的内容与bean中的字符串变量不同.这种方法有效但不是我想要的.我想知道为什么args对象是未定义的,或者我怎样才能从javascript中管理bean属性.谢谢.

javascript ajax primefaces

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