tags:

views:

152

answers:

2

I am developing a business application in .NET and Java. In .NET I have developed a web-service which uses basicHttpBinding. I am consuming this web-service in a Java client. The web-service is working fine, calling it in the Java code returns an ArrayList collection of Holding class. This class is described below:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Holding", propOrder = {
    "companyName",
    "price",
    "quantity",
    "scripCode"
})
public class Holding {

    @XmlElementRef(
        name = "CompanyName", 
        namespace = "http://schemas.datacontract.org/2004/07/JavaLIB", 
        type = JAXBElement.class)
    protected JAXBElement<String> companyName;

    @XmlElementRef(
        name = "Price", 
        namespace = "http://schemas.datacontract.org/2004/07/JavaLIB", 
        type = JAXBElement.class)
    protected JAXBElement<String> price;

    @XmlElementRef(
        name = "Quantity", 
        namespace = "http://schemas.datacontract.org/2004/07/JavaLIB", 
        type = JAXBElement.class)
    protected JAXBElement<String> quantity;

    @XmlElement(name = "ScripCode")
    protected Integer scripCode;

    /**
     * Gets the value of the companyName property.
     * 
     * @return
     *     possible object is
     *     {@link JAXBElement }{@code <}{@link String }{@code >}
     *     
     */
    public JAXBElement<String> getCompanyName() {
        return companyName;
    }

    /**
     * Sets the value of the companyName property.
     * 
     * @param value
     *     allowed object is
     *     {@link JAXBElement }{@code <}{@link String }{@code >}
     *     
     */
    public void setCompanyName(JAXBElement<String> value) {
        this.companyName = ((JAXBElement<String> ) value);
    }

    /**
     * Gets the value of the price property.
     * 
     * @return
     *     possible object is
     *     {@link JAXBElement }{@code <}{@link String }{@code >}
     *     
     */
    public JAXBElement<String> getPrice() {
        return price;
    }

    /**
     * Sets the value of the price property.
     * 
     * @param value
     *     allowed object is
     *     {@link JAXBElement }{@code <}{@link String }{@code >}
     *     
     */
    public void setPrice(JAXBElement<String> value) {
        this.price = ((JAXBElement<String> ) value);
    }

    /**
     * Gets the value of the quantity property.
     * 
     * @return
     *     possible object is
     *     {@link JAXBElement }{@code <}{@link String }{@code >}
     *     
     */
    public JAXBElement<String> getQuantity() {
        return quantity;
    }

    /**
     * Sets the value of the quantity property.
     * 
     * @param value
     *     allowed object is
     *     {@link JAXBElement }{@code <}{@link String }{@code >}
     *     
     */
    public void setQuantity(JAXBElement<String> value) {
        this.quantity = ((JAXBElement<String> ) value);
    }

    /**
     * Gets the value of the scripCode property.
     * 
     * @return
     *     possible object is
     *     {@link Integer }
     *     
     */
    public Integer getScripCode() {
        return scripCode;
    }

    /**
     * Sets the value of the scripCode property.
     * 
     * @param value
     *     allowed object is
     *     {@link Integer }
     *     
     */
    public void setScripCode(Integer value) {
        this.scripCode = value;
    }

}

My problem is that I don't know how to bind these ArrayList<Holding> to a JTable - I have not worked much on Swing.

If someone can provide a link to a good tutorial (other than the one on the Sun website - I have seen that) or can quickly guide me how to implement a TableModel class for it that would be great.

I also have to get data from web-service after each 5 second interval, so please also provide a tutorial describing how to re-bind.

+1  A: 

I guess this tutorial from Sun is what you need. You will find what you need to build directly the JTable containing your data. Some paragraphs later you can also find how to build a TableModel.

Enjoy!

Valentin Jacquemin
A: 

If someone can quickly guide me how to implement a TableModel class for it that would be great.

Check out the BeanTableModel entry. Although I doubt you will be able to use the BeanTableModel because of the JAXBElement code, you should be able to use the JButtonTableModel example which shows you how to extend my RowTableModel to create your custom model.

camickr