zwwcn

Just another WordPress.com site

Category Archives: RichFaces

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>

 

 

value is not valid in h:selectonemenu convertor Validation

The equals method of the entity should return true. What happened in my case is that the entity is lazy loaded, which got a class type of lazyinitializer.  overwrite the equals method solve the problem:

remove this code:

if (getClass() != obj.getClass())
return false;

 

pop up model panel after page loading

<rich:modalPanel left="auto" top="250" id="waitpanel"  showWhenRendered="#{backingBean.isErro}" minWidth="733" autosized="true">

this can be used to create system warning msg.

show a4j log in browser

<a4j:log popup="false"/>

This will create a box in your page with all the Ajax logs from Richfaces. Eventually, you can set popup="true" and then display the popup by Ctrl + Shift + L

There are many logs in this panel, but generally the important things to look at is the WARN or ERROR messages.

 

reference: http://stackoverflow.com/questions/3616482/no-component-found-to-process-as-ajaxsingle

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 "";

richfaces suggestion box doesn’t render outputpanel properly

The problem is  in the following example,when select customer from the suggestion box, it doesn’t rerender the contact fields.

The solution is to add a4j:region around the suggestionbox.

<rich:suggestionbox   id=”iaSuggest” for=”customerName” var=”customerVar” suggestionAction=”#{customerQuery.suggest}”
status=”none”>
<h:column>
<h:outputText value=”#{customerVar.name}” />
</h:column>

<a4j:support event=”onselect”
action=”#{myScheduleLicenseBookingController.selectCustomer(customerVar)}”
ajaxSingle=”true”
reRender=”contactFields”
>
</a4j:support>
</rich:suggestionbox>

<a4j:outputPanel id=”contactFields” layout=”none” styleClass=”float_left”>

some code here                     </a4j:outputPanel>

 

check whether a request is ajax request

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

 

inconsistent tab height in rich tabs

problem happens in IE, Safari. we should apply same height for all tabs.

<style type=”text/css”>
.rich-tab-header{ height:35px; }
</style>

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”/>

Conditional Rendering in ui:repeat or c:forEach

Tried the combination of ui:repeat and ui:fragment , didn’t work. for some reason it give wrong evaluation. forEach raise the “Must evaluate to a Collection, Map…” error.

The best solution is using single column h:datatable and ui:fragment.