Datatable problem

Hello togehter!

I have a Datatable with some columns that contain data and two columns that offer to modify or delete a row:

<h:column id="column3">

<f:facet name="header">

<h:outputText value=""/>

</f:facet>

<h:form id="detailFormRemove">

<h:panelGrid columns="2">

<h:commandButton value="remove" type="submit" actionListener="#{visit.removeFromList}" />

<h:inputHidden id="diagnosticIdRemove" value="#{diagnostic.id}" binding="#{visit.idToRemove}"/>

</h:panelGrid>

</h:form>

</h:column>

<h:column id="column4">

<f:facet name="header">

<h:outputText value=""/>

</f:facet>

<h:form id="detailFormModify">

<h:panelGrid columns="2">

<h:commandButton value="modify" type="submit" actionListener="#{visit.modifyFromList}" />

<h:inputHidden id="diagnosticIdModify" value="#{diagnostic.id}" binding="#{visit.idToModify}"/>

</h:panelGrid>

</h:form>

</h:column>

I habe the problem that only the remove button of the first row works.

I have no idea why.

Any ideas?

Thanks

[1269 byte] By [Markus1982a] at [2007-10-2 17:07:44]
# 1

I found out that with Mozilla firefox the romve buttton of the first row works and with Internet Explorer nothing.

The methods are not even called. (I tried debugging)

I noticed that when the server starts it has the following error:

IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: javax.faces.component.html.HtmlInputHidden

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: javax.faces.component.html.HtmlInputHidden

at java.io.ObjectInputStream.readObject0(Unknown Source)

at java.io.ObjectInputStream.defaultReadFields(Unknown Source)

at java.io.ObjectInputStream.readSerialData(Unknown Source)

at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

at java.io.ObjectInputStream.readObject0(Unknown Source)

at java.io.ObjectInputStream.readObject(Unknown Source)

at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1371)

at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:903)

at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:393)

at org.apache.catalina.session.StandardManager.load(StandardManager.java:320)

at org.apache.catalina.session.StandardManager.start(StandardManager.java:634)

at org.apache.catalina.core.ContainerBase.setManager(ContainerBase.java:431)

at org.apache.catalina.startup.ContextConfig.managerConfig(ContextConfig.java:391)

at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1042)

at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:255)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4053)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)

at org.apache.catalina.core.StandardService.start(StandardService.java:450)

at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)

at org.apache.catalina.startup.Catalina.start(Catalina.java:537)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)

Caused by: java.io.NotSerializableException: javax.faces.component.html.HtmlInputHidden

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1445)

at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:920)

at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:516)

at org.apache.catalina.session.StandardManager.unload(StandardManager.java:462)

at org.apache.catalina.session.StandardManager.stop(StandardManager.java:664)

at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4255)

at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1065)

at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1065)

at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:447)

at org.apache.catalina.core.StandardService.stop(StandardService.java:512)

at org.apache.catalina.core.StandardServer.stop(StandardServer.java:717)

at org.apache.catalina.startup.Catalina.stop(Catalina.java:586)

at org.apache.catalina.startup.Catalina.start(Catalina.java:561)

... 6 more

Any ideas?

Thanks a lot.

The id is a string and the idToRemove (idToModify) is a HtmlInputHidden.

Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
can you dump the HTML output of your datatable, just the first few rows.
tinashechipomhoa at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
And put the code of the bean too...
pringia at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

The html code of the datatable is:(one pic added)

<table id="visitForm:diagnostics" class="list-background">

<thead>

<tr>

<th scope="col">Picture</th>

<th scope="col">Diagnostic</th>

<th scope="col"></th>

<th scope="col"></th>

</tr>

</thead>

<tbody>

<tr>

<td><img src="C:\Temp-8590650533761389520WebWriterArchitektur.jpg" alt="" /></td>

<td></td>

<td><form id="visitForm:diagnostics:0:detailFormRemove" method="post" action="/Webprojekt/visit.faces" enctype="application/x-www-form-urlencoded">

<table>

<tbody>

<tr>

<td><input type="submit" name="visitForm:diagnostics:0:detailFormRemove:_id25" value="remove" /></td>

<td><input id="visitForm:diagnostics:0:detailFormRemove:diagnosticIdRemove" type="hidden" name="visitForm:diagnostics:0:detailFormRemove:diagnosticIdRemove" value="0" /></td>

</tr>

</tbody>

</table>

<input type="hidden" name="visitForm:diagnostics:0:detailFormRemove" value="visitForm:diagnostics:0:detailFormRemove" /></form></td>

<td><form id="visitForm:diagnostics:0:detailFormModify" method="post" action="/Webprojekt/visit.faces" enctype="application/x-www-form-urlencoded">

<table>

<tbody>

<tr>

<td><input type="submit" name="visitForm:diagnostics:0:detailFormModify:_id28" value="modify" /></td>

<td><input id="visitForm:diagnostics:0:detailFormModify:diagnosticIdModify" type="hidden" name="visitForm:diagnostics:0:detailFormModify:diagnosticIdModify" value="0" /></td>

</tr>

</tbody>

</table>

<input type="hidden" name="visitForm:diagnostics:0:detailFormModify" value="visitForm:diagnostics:0:detailFormModify" /></form></td>

</tr>

</tbody>

</table>

<input type="hidden" name="visitForm" value="visitForm" /></form>

</body>

<form id="linkDummyForm" name="linkDummyForm" style="display:inline" method="post" action="/Webprojekt/visit.faces"><input type="hidden" name="jscook_action" /><script type="text/javascript">function clear_linkDummyForm() {

var f = document.forms['linkDummyForm'];

f.elements['jscook_action'].value='';

f.target='';

}

clear_linkDummyForm();</script></form>

</html>

Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

This is my bean:

public String getDiagnostic() {

return diagnostic;

}

public void setDiagnostic(String diagnostic) {

this.diagnostic = diagnostic;

}

public String getPicture() {

return picture;

}

public void setPicture(String picture) {

this.picture = picture;

}

public HtmlInputHidden getIdToModify() {

return idToModify;

}

public void setIdToModify(HtmlInputHidden idToModify) {

this.idToModify = idToModify;

}

public HtmlInputHidden getIdToRemove() {

return idToRemove;

}

public void setIdToRemove(HtmlInputHidden idToRemove) {

this.idToRemove = idToRemove;

}

public UploadedFile getUploadedPicture() {

return uploadedPicture;

}

public void setUploadedPicture(UploadedFile uploadedPicture) {

this.uploadedPicture = uploadedPicture;

}

and this are my methods.

Thanks for your help

Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
you didn't put the code of the actions.
pringia at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

here it is, but they are not even called

public String removeFromList() {

System.out.println("HEREremove");

//String id = this.getRequestParameterValue("diagnosticId");

System.out.println("IDTOREMOVE"+idToRemove.getValue().toString());

//String paramValue = ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("diagnosticId");

//System.out.println("Hallo"+paramValue);

//diagnosticsVector.remove(0);

removeFromList((String)idToRemove.getValue());

idToRemove=null;

return "visit";

}

public String modifyFromList() {

System.out.println("HEREmodify");

System.out.println("IDTOMODIFY"+idToModify.getValue().toString());

//String paramValue = ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("diagnosticId");

//System.out.println("Hallo"+paramValue);

//diagnosticsVector.remove(0);

Diagnostic diag=removeFromList((String)idToModify.getValue());

picture=diag.getPicture();

diagnostic=diag.getDiagnostic();

idToModify=null;

return "visit";

}

Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

The problem is that you have actionListeners and not simple actions.

Right know you have action signatures.

Or you midufy to action, or you change the sugnature of your methods.

Here is the description:

actionListener A method binding that refers to a method with

this signature: void methodName(ActionEvent)

action If specified as a string: Directly specifies an outcome

used by the navigation handler to determine

the JSF page to load next as a result of

activating the button or link

If specified as a method binding: The method has this

signature: String methodName(); the string represents

the outcome

pringia at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Thanks for your help, but I just found that out myself, but it still doesn't work, any other idea?
Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
What have you now?Action or actionListener?Do you have an h:messages on your page?
pringia at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

I have action.

Because of the message:

I have to tables (now HTML and one dataTable)

In the HTML table I added:

<tr>

<h:messages style="color: red"/>

</tr>

and that shows all the messages I throw.

Do I have to do more to get to see the messages.

Thanks

Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12

by looking at your code I noticed that you have multiple form elements

simply put one form element and enclose the whole dataTable in one form element, dont NEST form element, your view is not even restored in your case.

do it like this

<h:form>

<h:dataTable>

.....

</h:dataTable>

</h:form>

get rid of any nested form element,

let me know hoe it goes

tinashechipomhoa at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13
Thanks for the hint, but it didn'T solve the problem.Any other idea?
Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 14
and it is not center, it is on the left side. But I don't think that has something to do with the mistake.
Markus1982a at 2007-7-13 18:22:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 15
Any other ideas/hints?
Markus1982a at 2007-7-20 23:10:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 16
Could you write what your problem is now and put the code again.
pringia at 2007-7-20 23:10:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 17

My problem is still that the buttons in the datatable don'T work.

(In the IE no button works, in the Mozilla only the first remove button works)

The actions behind the buttons are not even called, as the first things are println.

The Bean code is:

public String removeFromList() {

System.out.println("HEREremove");

System.out.println("IDTOREMOVE"+idToRemove.getValue().toString());

removeFromList((String)idToRemove.getValue());

idToRemove=null;

return "visit";

}

public String modifyFromList() {

System.out.println("HEREmodify");

System.out.println("IDTOMODIFY"+idToModify.getValue().toString());

Diagnostic diag=removeFromList((String)idToModify.getValue());

picture=diag.getPicture();

diagnostic=diag.getDiagnostic();

idToModify=null;

return "visit";

}

(id to remove is a HtmlInputHidden and idTomodify aswell)

The jsp code is:

<h:form>

<h:dataTable id="diagnostics" styleClass="list-background" value="#{visit.diagnostics}" var="diagnostic">

<h:messages style="color: red"/>

<h:column id="column1">

<f:facet name="header">

<h:outputText value="Picture"/>

</f:facet>

<h:graphicImage value="#{diagnostic.picture}"/>

</h:column>

<h:column id="column2">

<f:facet name="header">

<h:outputText value="Diagnostic"/>

</f:facet>

<h:outputText value="#{diagnostic.diagnostic}"/>

</h:column>

<h:column id="column3">

<f:facet name="header">

<h:outputText value=""/>

</f:facet>

<h:form id="detailFormRemove">

<h:panelGrid columns="2">

<h:commandButton value="remove" type="submit" action="#{visit.removeFromList}" />

<h:inputHidden id="diagnosticIdRemove" value="#{diagnostic.id}" binding="#{visit.idToRemove}"/>

</h:panelGrid>

</h:form>

</h:column>

<h:column id="column4">

<f:facet name="header">

<h:outputText value=""/>

</f:facet>

<h:form id="detailFormModify">

<h:panelGrid columns="2">

<h:commandButton value="modify" type="submit" action="#{visit.modifyFromList}" />

<h:inputHidden id="diagnosticIdModify" value="#{diagnostic.id}" binding="#{visit.idToModify}"/>

</h:panelGrid>

</h:form>

</h:column>

</h:dataTable>

</h:form>

Thanks a lot for your help!!!!!!!!!!!!!!!!!!!!!!!!!!!

Markus1982a at 2007-7-20 23:10:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 18
1) Put the datatable inside of on form only.2) Put the h:messages outside of the datatable.3) Is the visit bean well binded in faces-config.xml?4) What is the IDE that you are using?
pringia at 2007-7-20 23:10:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 19

The binding is like that:

<managed-bean>

<managed-bean-name>visit</managed-bean-name>

<managed-bean-class>hospital.datatypes.Visit</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

I use eclipse 3.1 and and apache tomcat 5.5

I have 2 forms one for the rest of the page and one for the datatable. except that the datatable is only in : body, f:view and html

I have for each column a form and one around the datatable.

Need help urgently thanks!!!!!!!!!!!!!!!!!!!!

Markus1982a at 2007-7-20 23:10:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 20
I deleted the form around and now it works.Thanks a lot for all help.
Markus1982a at 2007-7-20 23:10:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...