Thanks Darryl. I've solved the issue. Your suggestions really helped me. i was initially doing it in a more complicated manner.
MyPage.java
public class MyPage{
private List<HostObj> list = new ArrayList<HostObj>();
HostObj hostObj = null;
private HtmlDataTable table;
public List<HostObj> getList() {
return list;
}
public void setList(List<HostObj> list) {
this.list = list;
}
public HtmlDataTable getTable(){
return table;
}
public void setTable(HtmlDataTable table){
this.table = table;
}
public void addHost(ActionEvent ae){
hostObj = new HostObj();
hostObj.setIpAddress(hostObj.getIpAddress());
hostObj.setDirPath(hostObj.getDirPath());
hostObj.setJavaHome(hostObj.getJavaHome());
hostObj.setOracleHome(hostObj.getOracleHome());
list.add(hostObj);
}
public void removeHost(){
hostObj =(HostObj)table.getRowData();
list.remove(hostObj);
}
}
MyPage.jsp
<h:dataTable value="#{panelGrid.list}" var="loc" binding="#{panelGrid.table}">
<h:column>
<h:inputText value="#{loc.ipAddress}"/>
</h:column>
<h:column>
<h:outputText value="Secondary"/>
</h:column>
<h:column>
<h:inputText value="#{loc.dirPath}"/>
</h:column>
<h:column>
<h:inputText value="#{loc.javaHome}"/>
</h:column>
<h:column>
<h:inputText value="#{loc.oracleHome}"/>
</h:column>
<h:column>
<h:commandButton id="remove" styleClass="buttonStyle" value="Remove" action="#{panelGrid.removeHost}"/>
</h:column>
</h:dataTable>
<h:commandButton id="add" styleClass="buttonStyle" value="Add Component" actionListener="#{panelGrid.addHost}">
</h:commandButton>
And it's working fine!!!