[JBoss Seam] - Re: Need some clarification about seam-gen-ed EntityHome cla
by gavin.king@jboss.com
Depends upon whether the attribute is optional or not. If the FK column is nullable, an entity can be saved without a value for the FK.
You can see all this stuff by looking at the template:
public void wire()
| {
| <#foreach property in pojo.allPropertiesIterator>
| <#if c2h.isManyToOne(property)>
| <#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
| <#if parentPojo.shortName!=pojo.shortName>
| <#assign parentHomeName = util.lower(parentPojo.shortName) + "Home">
| <#assign setter = "set" + pojo.getPropertyName(property)>
| ${parentPojo.shortName} ${property.name}=${parentHomeName}.getDefinedInstance();
| if ( ${property.name}!=null )
| {
| getInstance().${setter}(${property.name});
| }
| </#if>
| </#if>
| </#foreach>
| }
|
| public boolean isWired()
| {
| <#foreach property in pojo.allPropertiesIterator>
| <#if (c2h.isManyToOne(property) && !property.optional)>
| <#assign getter = pojo.getGetterSignature(property)>
| if ( getInstance().${getter}()==null ) return false;
| </#if>
| </#foreach>
| return true;
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048326#4048326
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048326
18 years, 11 months
[JBoss Seam] - Did this -- but not working (Re: Newbei question: Page navig
by zwu_ca
Thanks for help -- this has been driving me crazy (more than 12 hours have been spent -- a newbie in Seam).
I think I did do this: Could you look at what's wrong with the navigation (I also include the related Java code). Your help will be much appreciated.
<page view-id="/home.xhtml">
<redirect view-id="/itemlist.xhtml"/>
<page view-id="/itemlist.xhtml" login-required="true" >
<navigation from-action="#{hotelBooking.cancel}">
<redirect view-id="/main.xhtml"/>
import javax.ejb.*;
/**
*
* @author WuZX
*/
@Local
public interface Itemlist
{
UploadedData getData();
String getMe();
void setMe(String me);
/*
public void setDamn(String id);
public String getDamn();
*/
public void destroy();
}
/**
*
* @author WuZX
*/
import static org.jboss.seam.ScopeType.STATELESS;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.RequestParameter;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Destroy;
import javax.ejb.Remove;
import javax.ejb.*;
import org.jboss.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateful
@Name("itemlist")
//@Scope(STATELESS)
public class ItemlistAction implements Itemlist {
//@In String id;
// private UploadedData uploadedData;
@PersistenceContext
private EntityManager em;
@RequestParameter("id")
private String id;
private static final Logger log = Logger.getLogger(ItemlistAction.class);
static
{
log.info("loading?****************");
}
/*public String getData()
{
return "data" + id;
}*/
//@Out
//@Factory("uploadedData")
public UploadedData getData()
{
log.info("get here" + id);
if (id == null )
{
//UploadedData uploadedData = new UploadedData();
//uploadedData.setTesting("testing");
return null;
}
return em.find(UploadedData.class, new Long(id));
}
public String getMe()
{
return id;
}
public void setMe(String me)
{
id = me;
}
public int getDataID()
{
return 3;
/* try
{
if (id != null)
return Integer.parseInt(id);
}
catch(Exception e)
{
}
return 0;
*/
}
@Destroy @Remove
public void destroy() {}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048321#4048321
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048321
18 years, 11 months