Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:32:14+00:00 2026-05-28T17:32:14+00:00

I am trying to do Insert Operation in a table. I display exiting records

  • 0

I am trying to do Insert Operation in a table. I display exiting records in a datatable and details are displayed in a panelGrid below the dataTable on selecting each row. panelGrid with blank inputText boxes are shown when user click NEW button. User Submits the new record and dataTable is refreshed.

On submit, I am getting error :

Nov 22, 2011 5:02:22 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
WARNING: Argument Error: Parameter targetClass is null
java.lang.NullPointerException: Argument Error: Parameter targetClass is null

Code is Given below:

<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;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:32:15+00:00Added an answer on May 28, 2026 at 5:32 pm

    Those value attributes are not right:

    <p:inputText readonly="#{myBean.editMode ? false : true}" value="#{myBean.editMode ? myBean.newRec.Field1 : myBean.currentRec.Field1}" />
    <p:inputText readonly="#{myBean.editMode ? false : true}" value="#{myBean.editMode ? myBean.newRec.Field2 : myBean.currentRec.Field2}" />
    

    Those values can be retrieved, but new values cannot be set. The following syntax will work:

    <p:inputText readonly="#{!myBean.editMode}" value="#{myBean[myBean.editMode ? 'newRec' : 'currentRec'].Field1}" />
    <p:inputText readonly="#{!myBean.editMode}" value="#{myBean[myBean.editMode ? 'newRec' : 'currentRec'].Field2}" />
    

    (note that I improved the readonly attribute evaluation as well)

    But much better is to use just one and same property for both edit modes and use the edit mode value in the action method to determine how to deal with it:

    <p:inputText readonly="#{!myBean.editMode}" value="#{myBean.rec.Field1}" />
    <p:inputText readonly="#{!myBean.editMode}" value="#{myBean.rec.Field2}" />
    

    with e.g.

    private Record rec;
    
    public void save() {
        if (editMode) {
            // Treat "rec" as "currentRec".
        } else {
            // Treat "rec" as "newRec".
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do an Insert operation using iBatis. INSERT INTO SCHEMA.TABLE (FIELD1, FIELD2,
I am trying to INSERT INTO a table using the input from another table.
I am trying to do an Insert, Update and Delete on a table in
This error is happening when I'm trying to insert values on a table belong
I'm getting a strange mysql error: when trying to insert a row into a
Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
I'm trying to insert some import lines into a python source file, but i
I was trying to insert new data into an existing XML file, but it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.