Foreign Key Constraints and Persistence Issues in Seam


2008-04-30 Digg! icurtain Delcious icurtain Technorati icurtain


public String persist() { //this forces the persist function to persist IbUser before Rcs User and avoids the FKC issue getEntityManager().persist(getInstance().getIbUser()); return super.persist(); }

finding values through hibernate

@Override public String persist(){ //check if the nlc is duplicated here if(getEntityManager().find(JourneyLocation.class, this.instance.getNlc())!=null){ getFacesMessages().add(FacesMessage.SEVERITY_ERROR, "#{messages.nlcExists}") ; return null; }else{ return super.persist(); } }

Vista Style Buttons CSS


2008-03-11 Digg! icurtain Delcious icurtain Technorati icurtain


Resizable Vista style buttons with a gradient in XHTML/CSS

As I had to spend an entire afternoon trying to get these to work I might as well post them

To get your lovely Vista Style buttons just screen shot Vista or make a rectangle with 2 gradients that meet.. then add a boarder and blend the corner pixels onto whatever backdrop you want to put them on.

Vista Button CSS

.buttonLeft {
background-image: url(button-right.gif);
background-repeat: no-repeat;
background-position: top right;
display:block;
float:left;
/*external border spacing*/
margin:4px;
}

.buttonRight {
background-image: url(button-left.gif);
background-repeat: no-repeat;
background-position: top left;
display:block;
}

.buttonCentre{
/*line-height pushes the display block to the full height of the containing image*/
line-height:26px;
/*Inner boarders*/
margin-left:4px;
margin-right:4px;
background-image: url(button-centre.gif);
background-repeat: repeat-x ;
background-position: top left;
display:block;
}

span.buttonCentre:hover{
background: url(button-centre-hover.gif) ;
}
span.buttonLeft:hover {
background-image: url(button-right-hover.gif);
}
span.buttonRight:hover {
background-image: url(button-left-hover.gif);
}

And then all you have to do is make a few containing spans and you have your buttons

<span class="buttonLeft">
<span class="buttonRight">
<span class="buttonCentre">
buttonText
</span>
</span>
</span>

like this: buttonText

To conclude - these buttons are infinitely horizontally resizable and do display properly - however the hover does not work perfectly, if you hit the outer nested elements they will hover without making the internal elements hover..


Seam - Database Image to Screen Output


2008-02-01 Digg! icurtain Delcious icurtain Technorati icurtain


front end

a4j:mediaOutput id = "telephone" element = "img" mimeTye = "image/png"
createContent = "#{imagePainter.drawImage}"
value="#{object.instance.objectId}"

in this code the object id is handed to the drawImage funtion - this function then looks up the record and populates et which has a byteArray stored on it - it then writes this out to the screen using a file output writer

back end

@Name("imagePainter")

public class ImagePainter {


@In("midasEntityManager")
private EntityManager em;


public void drawImage (OutputStream output, Object emblemTemplateId) throws IOException{


Object et = em.find(Object.class, objectId);

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(et.byteArrayData());

FileUtilities.write(byteArrayInputStream, output, 1024);

}

/* private List getEmblemTypeById(String queryString, String emblemTypeId) { List reportSet = new ArrayList(); Query emblemQuery = em.createNamedQuery(queryString); emblemQuery.setParameter("emblemTypeId", emblemTypeId); reportSet = (List)emblemQuery.getResultList(); return reportSet; }*/

}

public static void write(InputStream input, OutputStream output, int bufferSize) throws IOException {
byte[] buffer = new byte[bufferSize] ;
int readSize = -1 ;
while ( (readSize = input.read(buffer)) != -1) {
output.write(buffer, 0, readSize);
output.flush();
}
try {
input.close();
} finally {
output.close();
}
}


Cannot insert explicit value for identity column


2008-01-28 Digg! icurtain Delcious icurtain Technorati icurtain


ERROR [org.hibernate.util.JDBCExceptionReporter] Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF.

ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session

org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

Solution

Annotate the function in the bean with the following:

@GeneratedValue(strategy=GenerationType.AUTO)


seam back end code references


2007-11-23 Digg! icurtain Delcious icurtain Technorati icurtain


@Name sets the front end reference point to the entity bean

@Name("userList")
public class UserList extends EntityQuery {

User user = new User();

public User getUser(){
return user;
}

}

Front end the references it via

#{userList.user}


JSF RichFaces - Get Page Name


2007-11-19 Digg! icurtain Delcious icurtain Technorati icurtain


to get the page ID of the current page = #{facesContext.viewRoot.viewId}


drop-down box in RichFaces


2007-10-30 Digg! icurtain Delcious icurtain Technorati icurtain


  1. <div style="float:left;"> 
  2.    <input type="button" onclick="hideDiv({duration:0.7})" value="Hide" /> 
  3.    <input type="button" onclick="showDiv()" value="Show" /> 
  4.    <rich:effect   name="hideDiv"   for="bubox" type="BlindUp" /> 
  5.    <rich:effect   name="showDiv"   for="bubox" type="BlindDown" /> 
  6. </div> 
  7.                       
  8. <div style="float:left;width:200px;height36px;background-color:#DD0022;"> 
  9.    <rich:panel id="bubox" styleClass="box"> 
  10.       <f:facet name="header">BlindUp Effect</f:facet> 
  11.       <rich:effect event="onclick" type="BlindUp" params="duration:0.8" /> 
  12.       <rich:effect event="onclick"   for="bubox" type="BlindUp" params="delay:3.0,duration:0.5" /> 
  13.       <h:outputText value="Click to Activate" /> 
  14.    </rich:panel> 
  15. </div> 

Seam Fairies


2007-09-12 Digg! icurtain Delcious icurtain Technorati icurtain


Fields within Jboss Seam are magically populated by Seam fairies

Don't try to work out how or why.. they just are


Jboss Seam PermGen space crash


2007-09-10 Digg! icurtain Delcious icurtain Technorati icurtain


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:53)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:393)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

java.lang.OutOfMemoryError: PermGen space

note The full stack trace of the root cause is available in the JBossWeb/2.0.0.GA logs.

--------------------------------------------------------------------------------

JBossWeb/2.0.0.GA

This can be rectified by modifying run.sh to include a MaxPermSize parameter for JVM memory allocation

# Execute the JVM in the background
add # Setup JBoss sepecific properties
JAVA_OPTS="-XX:MaxPermSize=128M -Dprogram.name=$PROGNAME $JAVA_OPTS"

or

"$JAVA" $JAVA_OPTS \
-XX:MaxPermSize="128M" -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
-classpath "$JBOSS_CLASSPATH" \
org.jboss.Main "$@" &


Static and Dynamic List Options in JavaServer Faces


2007-07-25 Digg! icurtain Delcious icurtain Technorati icurtain


just a quick note on how to do database drive drop-downs and static list boxes in jsf

itemLabel="hello" />

itemLabel="hello again" />




value="#{qryActiveTypeCombo.resultList}"

var="ddDay"

label="#{ddDay}" />