Ajax with JSF -( No RichFaces / No Ajax4Jsf ) - jsf

I am using jsf portlets (JSR 168), and i am implementing ajax with JSF ( i have a text field and select one menu, on entering a char on the text field, should get the matching strings on the menu, an auto completion functionality). but i am not using any jsf adv specs like richfaces / facelets etc.. our project is using jdk1.4 still.
so i have a h:inputText with onkeyup event which calls javascript method and gets the values into select one menu. this works perfectly alright.
but later i am trying to submit the form with the textfield value and selectonemenu values using h:commandbutton.
there comes the issue, the action menthod in jsf bean is not getting invoked.
but when i tried removing the onkeyup event from the h:inputtext it works perfectly.
please suggest me. whatz goin on here.

got it resolved... there was a problem with my selectonemenu, it was not identifying the item when it is pulling from ajax. so replaced it with html select for now, but i will figureout a way to build the f:selectitem through javascript.

Related

PrimeFaces DataTable which is inside OverlayPanel stops working when OverlayPanel is used inside Dialog

Here is my scenario. Room Object have ManyToOne relationship with Tax Object. There are two pages for Room, Create New and List All.
At Create New Page, there is Tax Field. I use OverlayPanel + DataTable + SelectEvent to assign Tax Object instead of using AutoComplete or SelectOneMenu. Everything works great at this page.
At List All Page, I use Pop-up Dialog to edit the desired record. OverlayPanel + DataTable not working anymore because OverlayPanel is inside the Dialog. SelectEvent still calls Tax Setter Method but value is null.
I use PrimeFaces 3.5 and looking for solutions that will work with PrimeFaces 3.5 only. Thanks for any help!
I think OverlayPanel (DataTable inside) is not compatible with Dialog. Using Dialog again instead of OverlayPanel solved the problem. Dialog inside Dialog works fine. I have to add appendToBody="true" attribute to child Dialog because UI is blocked. I use PrimeFaces 3.5 and works for me.

Primefaces confirm dialog not centered when used in conjuntion with richfaces

As per my question title, when I use richfaces, specifically a rich:popupPanel, my primefaces confirm dialog, p:confirmDialog, gets placed top/left justified. If I remove the the richfaces popup panel the primefaces dialog gets centered in the browser window as expected.
I tried changing the order of the namespace entries but that didn't work. What else can I try. I see richfaces also has a confirm dialog that I'm going to look into, it's just that I already had the primefaces version working on other pages, that happen to not have the richfaces popup panel.
I can post code if necessary.
You should not use Richfaces and Primefaces together. There so many conflicts between them both in terms of css and javascript. You can solve css problems by overwriting them and using '!important' at the end of each setting.
for example,
.class{
//...
text-align: center !important
}
However, Your best bet is to use just primefaces

Primefaces Picklist problem

I am having a text field in my xhtml whose property i have set to required="true" and then i have primefaces picklist.
Now when validations fails like mandatory "textbox" is not filled. I throws an error and my page picklist becomes corrupted (all alignment) and if i see in generated html there will be no imports for primefaces like imports for picklist css and js.
I found the answere for the problem myself.
It was actually bcoz of a very silly problem.
One needs to do "render={SomeId of form element}" in the CommandButton.
All the things will work fine then.

JSF: Button/Link without form submit

In earlier projects I often used an s:button or s:link from Seam 2 when caceling something, because it wouldn't submit the form and thus no model updates occured.
Now I switched to WELD + Seam 3 and couldn't find it there anymore - am I just blind or do I have to use something else?
Geziefer
You can do it in plain JSF 2.0 by setting immediate attribute to true in the h:commandButton.
From the MyFaces wiki:
The immediate attribute can be used to achieve the following effects:
Allow a commandLink or commandButton to navigate the user to
another page without processing any data currently in input fields of
the current screen. In particular, this allows navigation to occur
even when there are currently validation errors. A "cancel" button
typically falls into this category.
Allow a commandLink or commandButton to trigger back-end logic
while ignoring validation for some of the fields on the screen. This
is a more general version of the item above.
Make one or more input components "high priority" for validation,
so that if any of these are invalid then validation is not performed
for any "low-priority" input components in the same page. This can
reduce the number of error messages shown.
I found a way to handle it by using the commandButton from RichFaces 4 and setting bypassUpdates to true:
<a4j:commandButton value="Cancel" action="#{myHandler.cancel}"
bypassUpdates="true" render="myTable" />
For me this solution is ok, since I'm allready using RichFaces 4 - but I'm still interested, how to solve this with standard JSF 2.0?

Problem With JSF 1.1 and PopUp

I am trying to popup a window when someone clicks a button on the data table.
<h:commandButton
action="#{cacheController.popupDetails}"
immediate="false"
onclick="popup()"
value="View Details"
styleClass="submit">
</h:commandButton>
The associated popup function is
function popup() {
window.open('RDDetails.jsf','popupWindow', 'dependent=yes, menubar=no, toolbar=no, height=500, width=400');
}
Now in the new 'RDDetails.jsf" file, I am trying to access the same managedBean cacheController. But the problem is, the pop-up window and JSF lifecycle is not in sync. As a result, the popup first displays blank and when I refresh, it pulls out the proper data.
Is there anyway I can click on a button which will do some processing in the managed bean and then opens a pop up which rerieves the processed data from the managed bean.
I am using JSF 1.1.
You're here basically firing two independent requests: one associated with the form submit and other which opens the RDDetails.jsf in a popup. You'll need to combine this in one request. You can achieve this in basically two ways:
Get rid of the onclick and just add target="_blank" to the <h:form> so that it get submitted into a new window/tab.
Block the default action by adding return false; to the onclick and do the business logic in the constructor of the bean associated with RDDetails.jsf. The only (major) caveat is here that the model won't be updated with the form fields. Thus, you'll need to pass the form fields as request parameters of the popup URL manually with help of JavaScript. You can then make use of managed property entries in the faces-config.xml to inject the GET request parameters into the model.
First way is obviously the easiest, but this doesn't give you a "fullworthy" popup/modal dialog. The second way is a bit harder (unless you've already a good grasp on both JavaScript and JSF). I would then consider to look for a component library which provides a ready-to-use popup component.
See my example:
<h:commandLink action="#{controller.myAction}" onmousedown="document.forms['idform'].target='_blank';">
I'm using jsf 1.1

Resources