[jboss-user] [EJB 3.0] - Re: Foreign key error
neisann
do-not-reply at jboss.com
Wed Aug 15 15:57:18 EDT 2007
Hi,
I have a JSP page that receives the data entered by the user. This page uses JSF.
* register.jsp:
| <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
| pageEncoding="ISO-8859-1"%>
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
| <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
| <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
| <%@ page errorPage="errorpage.jsp" %>
| ...
| <f:facet name="footer">
| <h:panelGroup>
| <h:commandButton value="#{msg.submit}"
| action="#{registrationBean.register}" />
| <h:commandButton value="#{msg.reset}" type="reset"/>
| </h:panelGroup>
| </f:facet>
| ...
| <h:outputLabel for="title" value="#{msg.registrationTitle}"/>
| <h:panelGroup>
| <h:inputText id="title" value="#{registrationBean.person.title}"
| maxlength="45" size="10"/><f:verbatim><br/></f:verbatim>
| <h:outputText value=" "/><h:message for="title" styleClass="formUserError"/>
| </h:panelGroup>
|
| <h:outputLabel for="firstName" value="#{msg.registrationName}"/>
| <h:panelGroup>
| <h:inputText id="firstName" value="#{registrationBean.person.firstName}"
| maxlength="255" size="30"/><f:verbatim><br/></f:verbatim>
| <h:outputText value=" "/><h:message for="firstName" styleClass="formUserError"/>
| </h:panelGroup>
| ...
| <h:outputLabel for="line1" value="#{msg.registrationAddress1}"/>
| <h:panelGroup>
| <h:inputText id="line1" value="#{registrationBean.person.address.line1}"
| maxlength="255" size="50"/> <f:verbatim><br/></f:verbatim>
| <h:outputText value=" "/><h:message for="line1" styleClass="formUserError"/>
| </h:panelGroup>
|
| <h:outputLabel for="postcode" value="#{msg.registrationPostcode}"/>
| <h:panelGroup>
| <h:inputText id="postcode" value="#{registrationBean.person.address.postcode}"
| maxlength="50" size="20"/><f:verbatim><br/></f:verbatim>
| <h:outputText value=" "/><h:message for="postcode" styleClass="formUserError"/>
| </h:panelGroup>
|
| <h:outputLabel for="country" value="#{msg.registrationCountry}"/>
| <h:panelGroup>
| <h:inputText id="country" value="#{registrationBean.person.address.country}"
| maxlength="150" size="40"/><f:verbatim><br/></f:verbatim>
| <h:outputText value=" "/><h:message for="country" styleClass="formUserError"/>
| </h:panelGroup>
|
The JSF configuration is:
* faces-config.xml:
| <managed-bean>
| <managed-bean-name>registrationBean</managed-bean-name>
| <managed-bean-class>app.web.Register</managed-bean-class>
| <managed-bean-scope>request</managed-bean-scope>
| <managed-property>
| <property-name>person</property-name>
| <value>#{registeringPersonBean}</value>
| </managed-property>
| </managed-bean>
|
| <managed-bean>
| <managed-bean-name>registeringPersonBean</managed-bean-name>
| <managed-bean-class>app.server.entities.Person</managed-bean-class>
| <managed-bean-scope>none</managed-bean-scope>
| <managed-property>
| <property-name>address</property-name>
| <value>#{addressBean}</value>
| </managed-property>
| <managed-property>
| <property-name>gender</property-name>
| <value>Undisclosed</value>
| </managed-property>
| <managed-property>
| <property-name>maritalStatus</property-name>
| <value>Undisclosed</value>
| </managed-property>
| </managed-bean>
|
| <managed-bean>
| <managed-bean-name>addressBean</managed-bean-name>
| <managed-bean-class>app.server.entities.Address</managed-bean-class>
| <managed-bean-scope>none</managed-bean-scope>
| </managed-bean>
|
So when the user enters the data in the JSP/JSF page and press submit the class Register.java is called with the Person ejb data filled, is that correct? As the Person ejb has the methods getAddress and setAddress, shouldn?t the entity manager create the records in the table Address and in the table Person?
Thank you again.
Nei
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074570#4074570
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074570
More information about the jboss-user
mailing list