I have an application that is somewhat heavy on ADF Popup dialogs. They will be defined in the index page like this:
<af:popup id="popup1" contentDelivery="lazyUncached" binding="managedBean1">
<jsp:include page="page1.jsp" />
</af:popup>
<af:popup id="popup2" contentDelivery="lazyUncached" binding="managedBean1">
<jsp:include page="page2.jsp" />
</af:popup>
etc, etc.
What I would like to do is whenever the popup opens and/or receives the focus, I want to set a session-scoped variable named "whereami". This variable will be used for further customization of pages, context menus, etc.
Can anyone assist?
Jason
You can attach click event to the body or div whatever, of the popup using JavaScript. And this can be achieved from backend by firing JavaScript from the Listener method of PopupFetchListener. As:
ExtendedRenderKitService service = Service.getRenderKitService(FacesContext.getCurrentInstance(), ExtendedRenderKitService.class);
service.addScript(FacesContext.getCurrentInstance(), "yourmethod();");
Then you can follow either of the following way.
Add a commandButton with actionListener and let it hidden. From the onclick JavaScript method of the popup you can trigger the click event of that hidden button by:
var button = AdfPage.PAGE.findComponentByAbsoluteId("hiddenButton");
ActionEvent.queue(button,true);
This will fire the actionListener.
Or you could take the help of af:serverListener to call backing method.
I didn't test it, but this should work.
The popup component has a PopupFetchListener event. The event is fired when the popup is displayed.
Capture that method in your backing bean and set your session bean there.
Related
In web layer of my project I am using ADF Faces component.In places I have used ADF popup element nested with dialog.
<af:popup id="myPopup" popupFetchListener="#{.....}">
<af:dialog contentWidth="400" title="Dialog Title" contentHeight="100" closeIconVisible="true"
modal="true" type="okCancel" id="d3"
dialogListener="#{mybean.myDialogListener}">
</af:dialog>
</af:popup>
In my backing bean I'm trapping the "ok"/"cancel" event with the help of DialogEvent class.
I want to change the label of framework build "ok" button to some custom label based upon my project requirement.If I add the desired label in message bundle how to reflect that in framework generated button?
Can anyone provide any clue for this?
You have to use the Type, AffirmativeTextAndAccessKey and CancelTextAndAccessKey properties of the dialog element.
To have the "ok" display "yes please" :
<af:popup id="myPopup" popupFetchListener="#{.....}">
<af:dialog contentWidth="400" title="Dialog Title" contentHeight="100" closeIconVisible="true"
modal="true" type="okCancel" id="d3"
dialogListener="#{mybean.myDialogListener}" type="yesNo" affirmativeTextAndAccessKey="yes please">
</af:dialog>
Note : it will change the type of the response in your dialog listener from
dialogEvent.Outcome.ok
to
dialogEvent.Outcome.yes
I am using a controller to get the form values from the html. And doing some kind of validations. If validation fails i want to reload that popup by throwing the validation message and the popup page view name to reload the popup page. Like
If i have a page A, in that page A there is a button B.
Now if i click the button B, there will be open a popup window C.
Here in the page C, if i click the form submit. It will goes to the controller.
Here in the controller i do some validations, if validation fails i just want to reload that popup page C with the error message.
Any body can help to overcome the issues.
It will be easy if you use jQuery UI Modal.
Just go through this link
Is this what you want to do here It can be achieved by basic JQuery, CSS, js. Explorer some. if you have to validate it from data base and than show use <f:ajax /> this is whole work do some effort
I have a button which opens a pop-up window and an Ajax update panel. Inside that window I have another button.
What code do I have to run if I want that update panel to be refreshed, when I press the button from the parent page, without refreshing the whole page?
I sow this code on a web which refreshes the page:
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
I am such a good friend with Java.
You need to utilize window.opener object.
window.opener.document.getElementById('Container').onclick();
I'd suggest using jQuery to ensure cross-browser compatibility. And also adding some null-checks of course.
Use Jquery :
If the DIV ID remains static :
$("#Container").click(function() {
// REFRESH CONTAINER HERE
});
If the Div ID is dynamic then make use of class instead of ID:
$(".Container").click(function() {
// REFRESH CONTAINER HERE
});
Does anyone know of any javascript code that I can put on a radio button that will kick off a Spring WebFlow2 Transition event?
I am looking to kick off a transition to load values into a dropdown if the user clicks on a radio button... can someone please tell me if you seen this done.
In your situation I think you want to use Ajax to refresh only part of your page. What I use is a function in my global js file:
function ajaxWebFlowSubmitGet(divID,pars,view) {
new Ajax.Updater({success:divID},
view+"&date="+new Date().getTime(),
{ method:'get',
parameters:pars,
evalScripts:true,
onFailure:reportError,
requestHeaders: ['Accept','text/html;type=ajax']
});
}
which you can use then in your code with
ajaxWebFlowSubmitGet('dropdownListDiv','_eventId=eventID&fragments=dropDownFragment',${flowExecutionUrl});
just put that 'ajaxWebFlowSubmitGet' function in your page and call it from your radiobutton.
'dropdownListDiv' is the div you want to get updated
eventID is the name of the transition from your webflow you want to execute
dropDownFragment is the name of the fragment you want to receive as a response (and to be put in your 'dropdownListDiv')
I have a form with validations in JSF that needs to be open in popup. When I submit the form, I am calling the bean method, the data send to the back end and if it successful then the pop up should close automatically.
Data is storing successfully, what should I need to return from bean method, so that the pop up will close automatically.
And also, How can we get the response after submitting the form? Is that possible?
Below code can be used to keep the show/hide the popup based upon the validation:
<a4j:commandButton value="Create Quote" id="createQuote" action="#{quoteAction.createQuote}"
immediate="false"
execute="envType country partner #this"
render="envType country partner"
oncomplete="if (#{facesContext.maximumSeverity == null}) {#{rich:component('quoteResultPanel')}.show();}">
</a4j:commandButton>
#{facesContext.maximumSeverity == null} will validate for any validation message(s) if this is not null then user will not be shown with the popup else user will be displayed with the popup. you can even use it the other way like close the popup only if there are no validation messages else keep the popup with the messages.
oncomplete="if (#{facesContext.maximumSeverity == null}) {#{rich:component('quoteResultPanel')}.hide();}"
Look here Using JavaServer Faces (JSF) Popup Window Example. Note that MyFaces Orchestra has support for multi-window applications out-of-the-box.
If you're using RichFaces, you might want to consider using a Rich Modal Window instead of a normal popup.
If your form is an <a4j:form>, you can use an <a4j:commandButton> for an ajax submit, and supply an oncomplete attribute to give it javascript to execute after successful submission. This javascript can be a call to Richfaces.hideModalPanel('pnl'); with the id of your modal as the argument.