zwwcn

Just another WordPress.com site

Category Archives: ajax

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>

 

 

Advertisements

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

check whether a request is ajax request

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

 

Validation Error: Value is not valid

this problem happens when you dynamically change the list for a selectonemenu or picklist, when you submit the form the selectitems are different from they were when the page is rendered.

solution: 1 in seam , we just need to make sure it’s  in a long running conversation. it won’t work if it’s event scope.

2 overrides equals  and hashcode method

JSF aj4 ajaxsingle=true

When ajaxsingle=true is used in the element then, while ajax submission only that particular element will be submitted instead of whole form.

Example when we have two drop down Country and state. Consider state is mandatory field and state is populated by a4jsupport of country drop down. If we are not making ajaxsingle=true in country drop down then required validation error will be thrown while selecting the country even before user selecting the state.