Error message when trying to access a property that is not defined in objects returned

I am currently utilizing DWR for AJAX implementation.
The method created by the creator is

 public ArrayList<CompanyRecord> step4QueryTable() throws JCoException
    {...}

The structure of CompanyRecord class is as follows:

public class CompanyRecord {
private String Code;
private String Name;
public void setValue(String value1,String column1)
{
    if (column1.equals("Code"))
    {
        this.Code=value1;
    }
    else 
    {
        this.Name=value1;
    }
}

public String getValue(String column1)
{

    if (column1.equals("Code"))
    {
        return Code;
    }
    else 
    {
        return Name;
    }
}

}

In dwr.xml, the converter was configured in the following manner:

<convert converter="bean" match="com.SCOfetch.CompanyRecord">
   <param name="include" value="Code,Name" />
</convert>

Within the JSP file, a method is implemented as shown below:

function bclick(){
    var result=[];
    SAPget.step4QueryTable(function(data){
        for(var i=0;i<data.length;i++){
             alert(data.Code);
            }
})}

However, the alert message always displays undefined. What could be missing? Any assistance would be appreciated. Thank you.

Answer №1

My CompanyRecord class was not considered a valid javaBean initially, but after some updates, it is now functioning properly.

public class CompanyRecord {


public CompanyRecord() {
        super();
    }

private String code;
private String name;
public void setValue(String value1,String column1)
{
    if (column1.equals("Code"))
    {
        this.code=value1;
    }
    else 
    {
        this.name=value1;
    }
}

public String getValue(String column1)
{

    if (column1.equals("Code"))
    {
        return code;
    }
    else 
    {
        return name;
    }
}

public String getCode() {
    return code;
}

public void setCode(String code) {
    this.code = code;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps for releasing a third-party library that is compatible with both Angular 2 and Angular 4

Currently, I am utilizing a third-party library for Angular that is compatible with Angular 2. However, I want to make sure this library can support all versions of Angular, including Angular 4 and Angular 5. How can I go about publishing an updated vers ...

Guide to converting a specific tag into div using Javascript

I am working with some HTML code that includes a div: <div class="myDiv"> <a href="" title="">My link</a> <p>This is a paragraph</p> <script>//This is a script</script> </div> Additionally, I ha ...

Embarking on the GSAP journey

I'm attempting my first animation using GSAP, but no matter what I try, nothing seems to be working. I've even tried using example code without success. Within my PHP file, I have the following code snippet: <head> <script src="https:/ ...

What is the best way to extract information from a dynamically generated bootstrap form with changing fields and names?

In my MERN app, I have implemented a Bootstrap form where users can input various martial arts styles such as judo and bjj. React-tag-component is used to manage these styles. As users enter their preferred style, it gets added to an array named selected. ...

the status of timers across various servers

I have come across a minor architecture issue that I am seeking help to resolve. My website sells products with limited inventory, and when a customer clicks the purchase button, my server updates the database with the details of the potential sale. This i ...

Issue with changing color of intersectObjects in Three.js not being properly registered [example code in jsfiddle]

I'm encountering an issue where I can't seem to change the color of a cube when someone hovers over it. I've simplified the code as much as possible. Click here for the code <script> var container; var scene, camera, renderer, mouse, ...

The v-menu closes before the v-list-item onclick event is detected

I have set up the following menu using vue and vuetify: <div id="app"> <v-app id="inspire"> <div class="text-center"> <v-menu> <template v-slot:activator="{ on }"> ...

Transforming PHP MySQL date into a Javascript timestamp for plotting time series data with FLOT

Currently, I am in the process of developing a Flot JavaScript Time Series Line Graph that analyzes the registration activity of users over time. The graph depicts the number of users registering accounts against the timestamp of when the account was creat ...

Implement the @Autowire annotation in your servlet code

I'm trying to implement @Autowired in my servlet to access external configurations. Below is the snippet of my servlet: public class DashboardServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final String USER_AGE ...

How to pass the table ID from one webpage to another using jQuery

I am dealing with 3 variations of tables that each have unique id values. My challenge is transitioning from one page to another and landing on the precise table within the new page. I'm uncertain about how to achieve this using jQuery. <table id= ...

The update functionality of the p:commandButton seems to be malfunctioning when used within a ui:include

Looking to refresh part of a page using PPR (Partial Page Rendering). This section of the page needs updating: <h:panelGroup id="aggiungiAuto" rendered="#{!autoBean.operazioneOk}"> <ui:include src="../component/aggiungi_ ...

several different objects within the rightIconButton of a ListItem component in MaterialUI

I am currently working on a project where I need to add multiple elements to the rightIconButton of a ListItem. The tools I am using are Material UI v0.20 and [email protected] <ListItem rightIconButton={ <span> ...

What is the proper method for utilizing a scanner to accurately read accented characters from a file?

Here's a method I've written: public static void readFile(String input) throws FileNotFoundException, IOException{ try (Scanner sc = new Scanner(new File(input));){ while (sc.hasNextLine()){ String curre ...

On IOS, Three.js ensures that the RGB values of a texture are set to zero whenever the ALPHA value

Working on a WebGL project utilizing javascript and the three.js framework, I am in the process of crafting a custom shader with GLSL. In this shader, I must load various lookup tables to utilize individual RGBA values for calculations rather than renderin ...

Ways to ensure the bootstrap table header width aligns perfectly with the body width

I am having an issue with my bootstrap table where the header width is smaller than the body width because I set the table width to auto. How can I align the header and body widths? Here is a link to a plunker showcasing the problem. https://plnkr.co/edit ...

The AJAX function fails to trigger the MVC controller method

I'm attempting to enable inline editing by cell, rather than by row, when double-clicking. Although the initial setup is working, it's not updating the record as expected - the "SaveCustomer" call to the controller isn't triggered. Can anyon ...

Unable to retrieve scripts upon returning to the main page of a Jquery website

Starting fresh with this post, I'm feeling incredibly frustrated and close to giving up on JQM completely. This shouldn't be so difficult. Here's my website structure: OUI/ index.php js/ pages/ images/ On the index.php page at http://loca ...

JavaScript Simplified Data Sorting after Reduction

I have extracted data from a JSON file and successfully condensed it to show the number of occurrences. Now, my next step is to arrange these occurrences in descending order, starting with the most frequent. To illustrate: var myData = [{ "datapo ...

Update the text on the button

I stumbled upon part of the solution at :jQuery change button text My quest is to find out how to toggle the button text. I attempted using the class method to switch between "show teams" and "hide teams". Simply changing the text property on button click ...

Calculating the time difference in days, hours, minutes, and seconds between two UNIX timestamps

I have a special occasion coming up, and the date and time for this event are stored in a Unix timestamp format. Instead of relying on a plugin like modern.js, I am trying to figure out the time difference between today's date and the event date usin ...