[
https://issues.jboss.org/browse/FORGE-797?page=com.atlassian.jira.plugin....
]
Antonio Goncalves commented on FORGE-797:
-----------------------------------------
We are now able to create embeddables [FORGE-1398] in Forge 2.x. But the JSF scaffolding
doesn't seem to work. Here is a script to create an embeddable, two entities and
scaffolding JSF :
{code}
project-new --named cdbookstore --topLevelPackage org.agoncal.training.javaee6adv --type
war --finalName cdbookstore ;
jpa-setup --persistenceUnitName cdbookstorePU ;
jpa-new-embeddable --named Address ;
jpa-new-field --named street1 ;
jpa-new-field --named street2 ;
jpa-new-field --named city ;
jpa-new-field --named state ;
jpa-new-field --named zipcode --columnName zip_code ;
jpa-new-field --named country ;
constraint-add --onProperty street1 --constraint Size --min 5 --max 50 ;
constraint-add --onProperty street1 --constraint NotNull ;
constraint-add --onProperty city --constraint Size --min 2 --max 50 ;
constraint-add --onProperty city --constraint NotNull ;
constraint-add --onProperty zipcode --constraint Size --min 1 --max 10 ;
constraint-add --onProperty zipcode --constraint NotNull ;
constraint-add --onProperty country --constraint Size --min 2 --max 50 ;
constraint-add --onProperty country --constraint NotNull ;
jpa-new-entity --named Customer ;
jpa-new-field --named firstname --columnName first_name ;
jpa-new-field --named lastname --columnName last_name ;
jpa-new-field --named telephone ;
jpa-new-field --named email ;
jpa-new-field --named dateOfBirth --type java.util.Date --columnName date_of_birth ;
jpa-new-field --named age --type int --transient
jpa-new-field --named homeAddress --type org.agoncal.training.javaee6adv.model.Address
--relationshipType Embedded ;
constraint-add --onProperty firstname --constraint Size --min 2 --max 50 ;
constraint-add --onProperty firstname --constraint NotNull ;
constraint-add --onProperty lastname --constraint Size --min 2 --max 50 ;
constraint-add --onProperty lastname --constraint NotNull ;
constraint-add --onProperty dateOfBirth --constraint Past ;
jpa-new-entity --named PurchaseOrder ;
jpa-new-field --named quantity --type int ;
jpa-new-field --named orderDate --type java.util.Date --columnName order_date ;
jpa-new-field --named deliveryAddress --type org.agoncal.training.javaee6adv.model.Address
--relationshipType Embedded ;
scaffold-generate --webRoot /admin --targets
org.agoncal.training.javaee6adv.model.Customer
scaffold-generate --webRoot /admin --targets
org.agoncal.training.javaee6adv.model.PurchaseOrder
{code}
Once the scaffolding is done, the JSF page looks like this :
{code}
<h:outputLabel value="Home Address:"/>
<h:panelGroup>
<h:commandLink action="#{customerBean.customer.newHomeAddress}"
rendered="#{empty customerBean.customer.homeAddress}" value="Create New
Home Address"/>
<h:panelGrid columnClasses="label,component,required"
columns="3" rendered="#{!empty
customerBean.customer.homeAddress}">
<h:outputLabel for="customerBeanCustomerHomeAddressStreet1"
value="Street 1:"/>
<h:panelGroup>
<h:inputText id="customerBeanCustomerHomeAddressStreet1"
maxLength="50" required="true"
value="#{customerBean.customer.homeAddress.street1}"/>
<h:message for="customerBeanCustomerHomeAddressStreet1"
styleClass="error"/>
</h:panelGroup>
{code}
It creates a {{h:commandLink}} with {{newHomeAddress}} just like a one to one
relationship. It shouldn't have this link and the embeddable should just be treated
like attributes of the entity.
Scaffolding @Embeddable
-----------------------
Key: FORGE-797
URL:
https://issues.jboss.org/browse/FORGE-797
Project: Forge
Issue Type: Feature Request
Components: Scaffold
Affects Versions: 1.2.1.Final
Environment: win 7, java 1.6_30, AS 7.1.1, JPA 2, Hibernate 4.1.7.Final
Reporter: Michael Koitz
Fix For: 2.x Future
Scaffolding should take the JPA2 annotations @Embeddable and @Embedded into account.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)