Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 素数运算_Jsf_Primefaces_Crud - Fatal编程技术网

Jsf 素数运算

Jsf 素数运算,jsf,primefaces,crud,Jsf,Primefaces,Crud,我正在尝试在表中执行插入操作。我在datatable中显示现有记录,在选择每一行时,详细信息显示在datatable下方的panelGrid中。当用户单击“新建”按钮时,将显示带有空白输入文本框的panelGrid。用户提交新记录并刷新数据表 提交时,我收到错误信息: 2011年11月22日下午5:02:22 com.sun.faces.lifecycle.ProcessValidationsPhase执行 警告:参数错误:参数targetClass为null java.lang.NullPoi

我正在尝试在表中执行插入操作。我在datatable中显示现有记录,在选择每一行时,详细信息显示在datatable下方的panelGrid中。当用户单击“新建”按钮时,将显示带有空白输入文本框的panelGrid。用户提交新记录并刷新数据表

提交时,我收到错误信息:

2011年11月22日下午5:02:22 com.sun.faces.lifecycle.ProcessValidationsPhase执行 警告:参数错误:参数targetClass为null java.lang.NullPointerException:参数错误:参数targetClass为null

代码如下:

<p:outputPanel header="MyTable Records" rendered="true" id="panel_MyTable">         
    <p:dataTable id="table_MyTable" value="#{myBean.records}" var="dataMyTable" onRowSelectUpdate="details_MyTable" selection="#{myBean.currentRec}" update="submitButton">
         <p:column>
               <f:facet name="header">
                    <h:outputLabel value="Label 1" />
               </f:facet>
               <h:outputLabel value="#{dataMyTable.Field1}"/>
         </p:column>

         <p:column>
             <f:facet name="header">
                 <h:outputLabel value="Label 2" />
             </f:facet>
             <h:outputLabel value="#{dataMyTable.Field2}"/>
         </p:column>

         <f:facet name="footer">
               <p:commandButton value="New"  image="ui-icon ui-icon-add" actionListener="#{myBean.prepareForInsertAction}" update="details_myTable,submitButton" />
         </f:facet>
  </p:dataTable>
</p:outputPanel>



<h:panelGrid id="details_MyTable">
    <h:outputLabel value="Label 1"/>
        <p:inputText readonly="#{myBean.editMode ? false : true}" value="#{myBean.editMode ? myBean.newRec.Field1 : myBean.currentRec.Field1}" />
        <h:outputLabel value="Label 2"/>
        <p:inputText readonly="#{myBean.editMode ? false : true}" value="#{myBean.editMode ? myBean.newRec.Field2 : myBean.currentRec.Field2}" />
</h:panelGrid>

<p:commandButton id="submitButton" actionListener="#{myBean.createAction}" value="Submit" update="table_MyTable,details_MyTable" rendered="#{myBean.editMode ? true : false}"/>




@ManagedBean(name="myBean")
@ViewScoped
public class MyBean
{
    public static List<MYTABLE> records;
    MYTABLE currentRec;
    Boolean editMode=false;

    public MyBean(){
        records = MYTABLE_CRUD.getAllRecs();
        currentRec = new MYTABLE();
    }

    public void prepareForInsertAction(){
        newRec = new MYTABLE();
        editMode = true;
    }
    public void setCurrentRec(MYTABLE v_currentRec) {
        this.currentRec = v_currentRec;
        editMode = false;
    }

}

@ManagedBean(name=“myBean”)
@视域
公共类MyBean
{
公共静态列表记录;
MYTABLE currentRec;
布尔编辑模式=假;
公共MyBean(){
records=MYTABLE_CRUD.getAllRecs();
currentRec=新的MYTABLE();
}
公共无效prepareForInsertAction(){
newRec=new MYTABLE();
editMode=true;
}
公共无效setCurrentRec(MYTABLE v_currentRec){
this.currentRec=v_currentRec;
editMode=false;
}
}

具有单个panelGrid,并使用它查看表行数据,以及根据panelGrid中InputExt值的动态绑定从用户处接受新记录详细信息
这是问题的根源。因此,我开始使用两个PanelGrid,一个用于查看现有表行数据,另一个用于接受来自用户的新记录数据。

那些
属性不正确:


可以检索这些值,但不能设置新值。以下语法将起作用:


(注意,我还改进了
只读
属性计算)

但更好的方法是对两种编辑模式仅使用一个相同的属性,并在操作方法中使用编辑模式值来确定如何处理它:


用例如

private Record rec;

public void save() {
    if (editMode) {
        // Treat "rec" as "currentRec".
    } else {
        // Treat "rec" as "newRec".
    }
}

不客气。这有助于解决你的具体问题吗?