English 中文(简体)
原始面 3.2 中正在下沉的 积层 3.2 无效
原标题:cascading dropdown in primefaces 3.2 not working

我希望在正本3.2中使用层层下沉,但无法工作。 下面是我的 xhtml 代码 :

<p:selectOneMenu style="width: 150px" value="#{watchBean.exchange}">
                    <f:selectItem itemLabel="NSE" itemValue="nse"/>
                    <f:selectItem itemLabel="BSE" itemValue="bse"/> 
                    <p:ajax event="change" update="sym" listener="#{watchBean.wow}" />
                </p:selectOneMenu> 
            <p:selectOneMenu style="width: 150px" id="sym" value="#{watchBean.sl}" var="scrip">
                <f:selectItems  itemLabel="#{scrip.scripSymbol}" itemValue="#{scrip.scripSymbol}"/>
            </p:selectOneMenu> 

豆代码 :

import java.util.List;
import javax.annotation.ManagedBean;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.ws.WebServiceRef;
import service.MasterScrip;
import service.StatelessWebService_Service;

/**
 *
 * @author root
 */
@javax.faces.bean.ManagedBean
@javax.faces.bean.RequestScoped
public class watchBean {
    @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/StatelessWebService/StatelessWebService.wsdl")
    private StatelessWebService_Service service;

    /** Creates a new instance of watchBean */
    public watchBean() {
    }
    String uname,scripSym,exchange;
    Integer scripID;
    List<UserTrack> ut;
List<MasterScrip> sl;
    public List<MasterScrip> getSl() {
        return sl;
    }

    public void setSl(List<MasterScrip> sl) {
        this.sl = sl;
    }


    public String getExchange() {

        return exchange;
    }

    public void setExchange(String exchange) {
        sl=getAllScripByExchange(exchange);
        setSl(sl);
        this.exchange = exchange;
    }
public void wow(ValueChangeEvent e)
{    
    sl=getAllScripByExchange((String)e.getNewValue());
   // setSl(sl);
    //FacesContext.getCurrentInstance().renderResponse();

    // sl=getAllScripByExchange(exchange);
} ....

i 获得以下错误:

javax.el.MethodNotFoundException: Method not found: [email protected](javax.faces.event.AjaxBehaviorEvent)

i referred to How do I get PrimeFaces <p:selectOneMenu> to call valueChangeListener? and removed the listener from my code, kept only the value attribute for 1st dropdown,still it doesnt work, then it gives no error and the 2nd dropdown isnt filled dynamically. i am stuck in this, what is the cause of this error and how can it be solved?

最佳回答

1) Remove parameter from method wow(). the ajax listener takes no parameter; when the method is executed, the attribute "exchange" contains the new value.
2) the selectOneMenus should be surrounded by h:form
3) The second selectOneMenu is wrong. the value attribute of the selectOneMenu should reference the selected item of the combo; not the list of items. the var attribute goes in the f:selectItems tag. the f:selectItems tag is missing the value attribute, which references the list of items. it should look like this:

<p:selectOneMenu style="width: 150px" id="sym" value="#{watchBean.selectedItem}" >
          <f:selectItems value="#{watchBean.sl}" var="scrip"
                         itemLabel="#{scrip.scripSymbol}"
                         itemValue="#{scrip.scripSymbol}"/>
</p:selectOneMenu> 
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签