aspose file tools*
The moose likes JSF and the fly likes yesno() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "yesno() " Watch "yesno() " New topic
Author

yesno()

odemir olivatti
Greenhorn

Joined: May 28, 2010
Posts: 2
Hello all, I am new with JSF and not sure if this can be done with Icefaces 1.8.2 ( + Jboss Seam 2.2)
Inside a bean method, I want to open a popup to the end user, get the answer,
and continue the method acording with the user s answer.
The jsf:
<ice:commandButton action="#{bean.command()}"
value="Start" id="poupupcmdId1" />

The bean method:
public void command()
{
log.info("start");
boolean answer=yesno("Yes or No ?"); // here, I need to render a popup and get the answer
if ( answer)
log.info("yes");
else
log.info("now);
log.info("end");
}

I did tried something based on the Seam s showcase Progress Bar, but the
rManager.getOnDemandRenderer(sessionId).requestRender(); only works after the JSF lifecycle.
Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16067
    
  21

HTTP, J2EE and JSF are not "client/server" systems in the sense that a server can send unsolicited messages (including pop-ups) to the client. Every request must have one and only one response, and no responses may be sent without a request being made from the client. The actual limitation is in HTTP protocol, but since that's what J2EE and JSF are built on - at least for what you're interested in - the limitation applies to all of them. In actual fact, there's no long-term connection to an HTTP server at all. Each request/response is effectively a one-shot session. We use various tricks such as HTTPSession to give the illusion of a continuous conversation, but in the end, it's only an illusion.

Usually what you end up doing is using JavaScript to ask the yes/no before the View is submitted. For example, in a Delete button's "onclick" function, ask "OK to Delete?" using a JavaScript confirmation dialog, then cancel the submit if the user clicks "Cancel". When JavaScript is disabled, you have to fall back to an "OK to delete" webpage instead, then either return to the original page or go forward if the delete is confirmed.


Customer surveys are for companies who didn't pay proper attention to begin with.
odemir olivatti
Greenhorn

Joined: May 28, 2010
Posts: 2
Hi Tim, thanks for the information, but I know a web 2 tools,named Unify NXJ(not open,and not JSF) that
has a feature like that.. I don´t know how they do, but they do...
About the a javascript to do the yesno before the submitting,
the Icefaces (where you can send information to the browser from the server using server side async rendering ) has the ice:panelConfirmation that works great for that.
Follow the Unify NXJ´s API for their yesno function
public final int optionButtonPrompt(String message,
String[] options,
int defaultOptionIndex,
int promptTimeoutInterval)
throws NXJPromptClientLostException
Prompts a message to the user during execution of an application. The optionButtonPrompt is used for prompting messages in a dialog. The dialog contains buttons for each of the options specified. Choosing a button returns the index of the option. Choosing Cancel returns -1. If the user does not respond within the specified time interval, it returns -2.
The optionButtonPrompt is used to display a prompt message with a set of buttons (one for each option, plus one for the Cancel button) used by the user to supply the answer. Choosing an option button returns the index of the option. Choosing Cancel (or closing the window) returns NXJSession.PROMPT_CANCEL (-1). If the user does not respond within the specified prompt timeout interval, the prompt is programatically dismissed and NXJSession.PROMPT_TIMEOUT (-2) is returned. If the specified prompt timeout interval is less than or equal to 0, then the prompt will not be programatically dismissed.


Parameters:
message - the prompt message (may include html markup).
options - the list of options to choose from.
defaultOptionIndex - the index of the option (zero-based) that should be indicated as the default.
promptTimeoutInterval - if greater than 0, the time interval (in seconds) to wait before the prompt times out; otherwise, the prompt will wait indefinitely.
Returns:
index of selected option (zero-based); NXJSession.PROMPT_CANCEL (-1), if the prompt was cancelled by the user; NXJSession.PROMPT_TIMEOUT (-2), if the prompt was programatically dismissed because the user did not respond within the specified prompt timeout interval. NXJSession.PROMPT_BLOCKED (-3), if the prompt was blocked by the browser.
Throws:
NXJPromptClientLostException - thrown if this thread has timed out waiting for the response. Typically, this occurs when the browser machine or network goes down. Note that this timeout is 300 seconds greater than the prompt timeout interval (if specified); hence, it gives the browser side javascript plenty of time to send the prompt timeout response. Whenever the prompt timeout response is 0, than this method uses the http session timeout value to determine how long it should wait before throwing this exception (in most Java application servers, this defaults to 30 minutes).
See Also:
messageBoxPrompt(java.lang.String), optionPrompt(java.lang.String, java.lang.String, java.lang.String[], int), optionListPrompt(java.lang.String, java.lang.String[], int)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16067
    
  21

UnifyNXJ uses AJAX. However, it's still going over HTTP. Therefore, you can't cause a JSF Action processor to post back in the middle of a process. There flat-out isn't a way to make an HTTP server make a request back to an HTTP client. The RFC doesn't permit it. HTTP clients don't have listener IP ports, for one thing, unlike HTTP servers. Only temporary reply ports bound to outgoing requests.

The best you can do server-side to get the illusion of asynchronous operation (and it's ONLY an illusion) is offload the work to another (externally-spawned!) thread and complete the current action request, using AJAX - whether UnifyNXJ or whatever - to poll the thread for completion. Which obviously is a bad fit if you intended to do server-side confirmation, instead.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: yesno()