zwwcn

Just another WordPress.com site

Category Archives: SEAM

js script to check ajax page change

We could add break point in firebug to check ajax page changes

<script type=”text/javascript” language=”javascript”>
document.documentElement.addEventListener(‘mouseup’, function(e){
mouseDown = false;
var str = “Mouse up”;
});
</script>

 

 

use Jmeter to do performance testing for seam project

1 Use Badboy to record action, export script for Jmeter

2 import script into jmeter

3 We need to handle two things, jsfViewState and conversation ID:

Add URL re-writing modifier for jsfViewState at root level, this only need to be done once

jsfViewState

Add regular expression extractor for cid(this should be done at the previous page, before the cid variable get called)

cidReg

update form data to load value from variables:

cid

userDefinedVariables

4 change all http sampler to use “Follow Redirects”

redirect

5 you should be able to run test test scripts now, run test, add “view results tree” listener to check request/response data

 

clear entered value in model panel

We could use facescontext to clear entered data in model panel.


selectedCustomer = null;

FacesContext context  = FacesContext.getCurrentInstance();
context.getViewRoot().findComponent("custPanel").getChildren().clear();
return "";

check whether a request is ajax request

public static boolean isAjax(request) {
return “XMLHttpRequest”.equals(request.getHeader(“X-Requested-With”));
}

 

seam code to show current conversations

<h:dataTable value=”#{conversationList}”
var=”entry”>
<h:column>
<h:commandLink action=”#{entry.select}”
value=”#{entry.description}”/>
<h:outputText value=”[current]”
rendered=”#{entry.current}”/>
</h:column>
<h:column>
<h:outputText
value=”#{entry.id}  ”/>
</h:column>
<h:column>
<h:outputText value=”#{entry.startDatetime}”>
<f:convertDateTime type=”time”
pattern=”hh:mm”/>
</h:outputText>
</h:column>
</h:dataTable>

jsf popup panel validation

Around the content with s:validateAll tag, and then add oncomplete attribute on the save button.

<a4j:commandButton oncomplete=”if (#{facesContext.maximumSeverity == null}){Richfaces.hideModalPanel(‘trackingFieldPanel’)}”/>
If there’s any validation error, the window will stay open.

validation on jsf popup model panel

if validation failed , popup should remain open

msgPanel is the output panel inside the  popup model panel

<a4j:commandButton id=”saveActivity” action=”#{createActivity.saveActivity}” value=”Save”
styleClass=”btn alignright btn_green smallFont” reRender=”msgPanel,activitiesList”
oncomplete=”if (#{facesContext.maximumSeverity == null}){closeModalPanel(‘activityPanel’);return false}”/>

ConcurrentRequestTimeoutException

Quoted from https://community.jboss.org/message/684147#684147

We were ending a conversation programatically, by calling Conversation.endBeforeRedirect(). However, there was no redirect, so the conversation lock wasn’t released.

I changed it to be Conversation.end() and then Conversation.leave(), which causes the conversation to end, release the lock and start a new one. And so far no exceptions 🙂

——————-

found this from http://riyazmsm.blogspot.com/2009/08/concurrent-calls-to-conversational.html
it came from Seam documentation

Accessing a Seam conversational component from a Ajax request need to be queued serially because as per the seam documentation ,conversational component dont allow concurrency. If the server component takes a long time to respond and if another request goes in, it throws out the “org.jboss.seam.ConcurrentRequestTimeoutException: Concurrent call to conversation” error. After adding the eventsQueue property to the a4j:support tag it stopped throwing out the Error.

The documentation explanation about the eventsQueue.  “eventsQueue – provide a queue in which events are placed. All events are queued and requests are sent to the server serially. This is useful if the request can to the server can take some time to execute (e.g. heavy computation, retrieving information from a slow source) as the server isn’t flooded.
view plainprint?

<a:support event=”onchange”  eventsQueue=”default” action=”#{longRunningComo}” reRender=”Decoration”
bypassUpdates=”true” ajaxSingle=”true”/>

setEntities and LIE

advisorFranchiseeComplianceCheckList.remove(selectedComplianceCheck);
em.remove(complianceCheck);
selectedComplianceCheck=null;
em.flush();
setEntities(advisorFranchiseeComplianceCheckList);
return “”;

 

the above code throws exception “failed to lazily initialize a collection, no session or session was closed”.
Solution: we should do setEntities before the flush call.

advisorFranchiseeComplianceCheckList.remove(selectedComplianceCheck);
em.remove(complianceCheck);
setEntities(advisorFranchiseeComplianceCheckList);
selectedComplianceCheck=null;
em.flush();
return “”;

 

 

@In attribute requires non-null value

I got this exception even I added @In(create=true) didn’t solve the problem.

it turns out that the variable name must match the seam component name.

e.g:

@AutoCreate
@Stateful
@Scope(ScopeType.CONVERSATION)
@Name(“oneplaceGoogleSchedularAction”)
@Synchronized
public class OneplaceGoogleSchedularAction …..

———————

@In(create = true)
OneplaceGoogleSchedular oneplaceGoogleSchedularAction ;