Hibernate Annotations or xml SQL-Mapping?
commy Aug 31, 2006 5:48 AMHi there!
I have a Problem with a project. We use Hibernate to store and manage persistent objects. At the moment, we use xml mapping files. But I'm not sure if it satisfies our needs.
The problem is: we use JSF. Saving new data is no problem, but edit allready stored data? I can't get it to work.
I tried the following:
The resource.java is mapped with a normal xml file, no problem with that.
Here's a jsf table with all the resources.
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
<h:form>
<f:verbatim>
<b>Resources
</f:verbatim>
<h:dataTable value="#{resourceutil.resources}" var="resource">
<h:column>
<f:facet name="header">
<h:outputText value="id" />
</f:facet>
<h:outputText value="#{resource.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="name" />
</f:facet>
<h:outputText value="#{resource.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="desc" />
</f:facet>
<h:outputText value="#{resource.description}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="edit" />
</f:facet>
<h:commandLink action="#{resource.edit}" value="edit"><f:param name="id" value="#{resource.id}"/></h:commandLink>
</h:column>
</h:dataTable>
<br />
</h:form>
<h:form>
<h:commandButton action="addResource" value="Add" />
</h:form>
</f:view>
By clicking edit, i'd like to het on a page to edit the data stored in the resources.
resource.edit() returns a value, and we are navigate (by jsf navigation rules) to the following page:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
<div align="left">
<h:form>
<f:verbatim>
<b>Add or Edit a Resource
</f:verbatim>
<h:panelGrid columns="2">
<h:outputText styleClass="portlet-font" value="Resource Name:" />
<h:inputText value="#{resource.name}" align="center" required="true" />
<h:outputText styleClass="portlet-font" value="Resource Description:" />
<h:inputText value="#{resource.description}" align="center"
required="true" />
</h:panelGrid>
<br />
<h:commandButton action="#{resource.save}" value="Add" />
</h:form>
<h:form>
<h:commandButton action="viewResources" value="View Resources" />
</h:form>
</div>
</f:view>
How can i tell jsf which object it has to display? Or can I only do this if i use annotations / ejb?
I'm very thankfull for every information
Greetings, Markus