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(); } }
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.
.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>
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..
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
@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}
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();
}
}
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
Annotate the function in the bean with the following:
@GeneratedValue(strategy=GenerationType.AUTO)
@Name sets the front end reference point to the entity bean
@Name("userList")
public class UserList extends EntityQuery {
public User getUser(){
return user;
}
Front end the references it via
#{userList.user}
to get the page ID of the current page = #{facesContext.viewRoot.viewId}
Fields within Jboss Seam are magically populated by Seam fairies
Don't try to work out how or why.. they just are
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 "$@" &
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}" />