If Seam Faces or PrettyFaces is being used then their view action ability would be used. If vanilla JSF is being used, then we need to figure out the best way to make this happen, which it looks like isn&#39;t all that easy :(<div>

<br></div><div>The idea is in the method would set a new instance of Address on the class so it&#39;s instantiated when the user goes to fill it out. Of course if things aren&#39;t filled out then you&#39;d have an empty address instance persisted, could be good or bad, that really depends on the app.</div>

<div><br></div><div>I know that&#39;s a fairly simplistic explanation, but it is the high level idea. Did it come across clearly?<br><br><div class="gmail_quote">On Tue, Nov 8, 2011 at 22:27, Richard Kennard <span dir="ltr">&lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Jason,<br>
<br>
Okay agreed. Could you explain how you would see the &#39;view action&#39; approach working?<br>
<span class="HOEnZb"><font color="#888888"><br>
Richard.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 9/11/2011 4:24 PM, Jason Porter wrote:<br>
&gt; It may boil down to which way we believe is the &quot;correct&quot; way. For all of the Forge plugins we&#39;ve been trying to have then generated code use best practices.<br>
&gt;<br>
&gt; This helps lessen support as hopefully, the patterns will be repeated and they&#39;ll be done correctly with fewer bugs. This approach also helps to educate people, though we could certainly do a better job at that by documenting why Forge is generating code a certain way.<br>


&gt;<br>
&gt; I suggested my proposal as I view this as an interaction problem with the persistence model, not a problem with that model. Therefore, my solution kept the fix closer to the problem, or at least as I see it, it does :)<br>


&gt;<br>
&gt; However, I&#39;m not tied to a particular solution and could be persuaded to others. I think some more discussion will provide a good approach.<br>
&gt;<br>
&gt; Sent from my iPhone<br>
&gt;<br>
&gt; On Nov 8, 2011, at 22:15, Richard Kennard &lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; I don&#39;t believe it will upset JPA, no. It *would* if you did:<br>
&gt;&gt;<br>
&gt;&gt;    public Address getAddress() {<br>
&gt;&gt;        if ( this.address == null ) { this.address = new Address(); }<br>
&gt;&gt;        return address;<br>
&gt;&gt;    }<br>
&gt;&gt;<br>
&gt;&gt; Because JPA will call setAddress(null) and then getAddress() and get back a different result. But if the field is just initialised to a default value...<br>
&gt;&gt;<br>
&gt;&gt;    private Address address = new Address();<br>
&gt;&gt;<br>
&gt;&gt; ...then JPA will overwrite it with setAddress(null) and it&#39;ll be okay.<br>
&gt;&gt;<br>
&gt;&gt; But sure, if there is a nicer way to do it I don&#39;t mind doing it a different way?<br>
&gt;&gt;<br>
&gt;&gt; Richard.<br>
&gt;&gt;<br>
&gt;&gt; On 9/11/2011 4:11 PM, Jason Porter wrote:<br>
&gt;&gt;&gt; Won&#39;t this cause issues with the JPA impl? From my conversations with the Hibernate devs if what is returned from the property (getter/field) is not what was set by JPA then extra db actions are performed.<br>


&gt;&gt;&gt;<br>
&gt;&gt;&gt; IMO, this an integration point for the JSF or EL specs. I think, though, this is an instantiation issue and should be done with a view action instead.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Sent from my iPhone<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Nov 8, 2011, at 21:37, Richard Kennard &lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi guys,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; As you&#39;re probably aware, in JSF if I do...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   #{customer}<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ...then a Customer object will get instantiated &#39;just in time&#39;. But if I do...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   #{customer.address.street}<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ...then &#39;address&#39; will *not* get instantiated just in time. So if you use Forge to do...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   entity --named Customer<br>
&gt;&gt;&gt;&gt;   field custom --named address<br>
&gt;&gt;&gt;&gt;   [what custom type m&#39;lord?] com.test.domain.Address<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Then although you&#39;ll get a UI that includes a Customer with an embedded Address, it&#39;ll fail as soon as you try to save. There isn&#39;t a very good solution to<br>
&gt;&gt;&gt;&gt; this, so can I suggest the simplest?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; When Forge generates field/getter/setter for a custom type (possibly limited to the project&#39;s domain package), could it do:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   @Column<br>
&gt;&gt;&gt;&gt;   private Address address *=new Address();*<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   public Address getAddress() {<br>
&gt;&gt;&gt;&gt;       return this.address;<br>
&gt;&gt;&gt;&gt;   }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   public void setAddress(final Address address) {<br>
&gt;&gt;&gt;&gt;       this.address = address;<br>
&gt;&gt;&gt;&gt;   } }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; forge-dev mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; forge-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; forge-dev mailing list<br>
&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt; _______________________________________________<br>
&gt; forge-dev mailing list<br>
&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jason Porter<br><a href="http://lightguard-jp.blogspot.com" target="_blank">http://lightguard-jp.blogspot.com</a><br><a href="http://twitter.com/lightguardjp" target="_blank">http://twitter.com/lightguardjp</a><br>

<br>Software Engineer<br>Open Source Advocate<br>Author of Seam Catch - Next Generation Java Exception Handling<br><br>PGP key id: 926CCFF5<br>PGP key available at: <a href="http://keyserver.net" target="_blank">keyserver.net</a>, <a href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>


</div>