|
Decision Center API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ilog.webui.dhtml.IlxWPort
public class IlxWPort
IlxWPort
represents a port for printing web components to an
HTML page.
A port encapsulates the writer of the servlet response given in
the IlxWPort
constructor.
When you display components on an HTML page through an IlxWPort
,
component deployers must always call the open()
method
before printing any components, and the close()
method after
having printed all components they want to display on the page.
The following code example shows how to do a print operation using a
IlxWPort
instance.
public void doPrint(IlxWPort port,boolean readonly,HttpSession session, HttpServletResponse response, IlrBusinessRule element) throws Exception { port.open(); if (readonly) { IlrSession rtsSession = element.getSession(); String html = getHTMLDefinition(rtsSession,(IlrDecisionTable)element); port.getXmlWriter().print(html); } else { DTableEditor tableEditor = new DTableEditor(element.getSession(), session, (IlrDecisionTable)element); tableEditor.print(port); } port.close(); }
IlxWComponent.print(ilog.webui.dhtml.IlxWPort)
,
IlxWManager
Field Summary | |
---|---|
static String |
PARENT_WINDOW_NOT_IN_SAME_DOMAIN
|
Constructor Summary | |
---|---|
IlxWPort(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.ServletOutputStream out)
Constructs a new port. |
|
IlxWPort(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Writer out)
Constructs a new port. |
Method Summary | |
---|---|
void |
addDependency(ilog.webui.dhtml.IlxWDependencyProvider user,
ilog.webui.dhtml.IlxWDependencyProvider used)
|
void |
addUpdatingRequest(IlxWRequestDesc desc)
Adds an updating request descriptor to the manager's updating request list. |
void |
close()
Ends printing to the port. |
void |
closeForm()
Closes a form. |
String |
disableOnload(String jsCode)
Gets the given Javascript code and wraps it in an if-then block which will execute the given code only if the page is not locked. |
void |
generateIFrames(int portNumber)
|
Object |
getAttribute(String string)
Returns the object bound with the specified name in this port, or null if no object is bound under that name. |
IlxWBrowserInfo |
getBrowserInfo()
Gets the browser information object associated with this port. |
javax.servlet.ServletContext |
getContext()
Gets the servlet context associated with this port. |
static IlxWPort |
getCurrentPort()
Gets the current port. |
boolean |
getEncloseInForm()
Gets the EncloseInForm flag. |
String |
getFloatingWindowName()
|
javax.servlet.http.HttpServletRequest |
getRequest()
Gets the servlet request associated with this port. |
javax.servlet.http.HttpServletResponse |
getResponse()
Gets the servlet response associated with this port. |
String |
getServletPath()
Gets the path of the controller servlet on the server. |
String |
getViewServletPath()
|
PrintWriter |
getWriter()
Gets the writer encapsulated by this port. |
protected void |
initResponse()
Initializes the response. |
void |
invalidatePage()
Invalidates the whole page. |
void |
invokeLater(Runnable doRun)
Causes doRun.run() to be executed asynchronously. |
boolean |
isGenerateIFramesInClose()
|
void |
open()
Opens the port. |
void |
openForm()
Opens a form. |
void |
setAttribute(String string,
Object value)
Binds an object to this port, using the specified name. |
void |
setEncloseInForm(boolean b)
Sets the EncloseInForm flag. |
void |
setFloatingWindowName(String floatingWindowName)
|
void |
setGenerateIFramesInClose(boolean flag)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PARENT_WINDOW_NOT_IN_SAME_DOMAIN
Constructor Detail |
---|
public IlxWPort(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Writer out)
context
- The current servlet context.request
- The current request.response
- The current response.out
- The writer where the HTML page will be printed. Typically,
this is either the writer given by the response passed in the
doGet/doPost
method of a servlet, or the out
variable of a JSP page.public IlxWPort(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletOutputStream out)
context
- The current servlet context.request
- The current request.response
- The current response.out
- The ServletOutputStream
where the HTML page will be
printed. Typically, this is either the stream given by the
response passed in the doGet/doPost
method of a servlet,
or the out
variable of a JSP page.Method Detail |
---|
public void setAttribute(String string, Object value)
string
- The name to which the object is bound;
cannot be null
.value
- The object to be bound; cannot be null
.public Object getAttribute(String string)
null
if no object is bound under that name.
string
- A string specifying the name of the object.
public PrintWriter getWriter()
PrintWriter
has its autoflush
property
set to true
. Do not forget to call one of the
println
method in order to flush the underlying buffer.
IllegalStateException
- if the port has no output
stream already set.
PrintWriter
public void setGenerateIFramesInClose(boolean flag)
public boolean isGenerateIFramesInClose()
public IlxWBrowserInfo getBrowserInfo()
public String getServletPath()
IlxWController
public String getFloatingWindowName()
public void setFloatingWindowName(String floatingWindowName)
public String getViewServletPath()
public void open() throws IOException
IOException
- if an error occurs while printing
to the current writer.
IOException
close()
,
IlxWComponent.print(ilog.webui.dhtml.IlxWPort)
public void addDependency(ilog.webui.dhtml.IlxWDependencyProvider user, ilog.webui.dhtml.IlxWDependencyProvider used)
public void close() throws IOException
IOException
- if an error occurs while printing on
the current writer.
java.lang.IllegalStateException
- if the port is not
open.
IOException
open()
,
IlxWComponent.print(ilog.webui.dhtml.IlxWPort)
public void generateIFrames(int portNumber) throws IOException
IOException
public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.ServletContext getContext()
protected void initResponse()
open()
method and initializes
the headers of the current response, asking the page not to be
cached on the web browser and setting the content type of the
page to text/html.
Usually, you do not have to change this behavior.
Nevertheless, if you wish to initialize headers in a different way,
you may write your own IlxWPort
class and redefine the
initResponse
method.
public void openForm() throws IOException
IOException
public void closeForm() throws IOException
IOException
openForm()
public static IlxWPort getCurrentPort()
ThreadLocal
variable.
This method is intended to be used in order to retrieve the current
port in a context where the port is not directly accessible through
the current scope (as a parameter of the current method, for instance).
Under certain circumstances, you may need to retrieve the current port
through this method.
Suppose for instance you want to add a tree model listener
(javax.swing.tree.TreeModelListener
) on the
tree component (ilog.webui.dhtml.components.IlxWTree
),
and need the value of a request parameter in one of the listener
method.
As the port is not directly accessible from the
treeXXX(TreeModel)
methods, you will have to retrieve the
port with getCurrentPort
. Here is the code you will
typically write:
class MyTreeModelListener implements TreeModelListener { public void treeNodesChanged(TreeModelEvent e) { IlxWPort port = IlxWPort.getCurrentPort(); if (port!=null) { String myParam = port.getRequest().getParameter("myParam"); System.err.println("myParam: "+myParam); ... } } }When using
IlxWPort.getCurrentPort
you should always
test if the returned port is null
in case the current
execution context is outside a web components request/response
context.
null
.
public void invalidatePage()
IMPLEMENTATION NOTE: Calling this method has the same effect than calling:
port.addUpdatingRequest(IlxWRequestDesc("myjsp.jsp", "_self"))but this is much more efficient as the page is directly forwarded in the current response instead of being requested from the client.
public void addUpdatingRequest(IlxWRequestDesc desc)
The updating request list is sent to the client the next time a port associated with the manager's session is closed (by @{link IlxWPort#close}): a JavaScript code block is appended to the end of the HTML page to ask the specified requests to be sent to the server. Once is has been printed, the updating request list is cleared.
desc
- The request descriptor giving the path of the request
to send and the name of the target frame where the response will
be displayed.public void setEncloseInForm(boolean b)
EncloseInForm
flag.
By default, this flag is true, meaning that the open()
and close()
methods respectively generate the <form>
and </form> HTML tags.
openForm()
and
closeForm()
methods). However, in some cases, you may not want
this HTML form to be printed. For instance, you may already have
printed a <form>
opening tag in your HTML page and
because nested forms are usually not supported by web browsers,
you may experience some problems. In those cases, you must set
the encloseInForm
flag to false
.
open()
,
close()
,
openForm()
,
closeForm()
public boolean getEncloseInForm()
EncloseInForm
flag.
setEncloseInForm(boolean)
public void invokeLater(Runnable doRun)
doRun.run()
to be executed asynchronously.
This will happen after all pending events of the current incoming request
have been processed, and just before sending the response.
public String disableOnload(String jsCode)
If, in the implementation of a web component proxy, you want to perform a client interaction which manipulates the client side of the framework, for instance call the JavaScript method IlxWPort.sendData() when a link is clicked, you should always protect your call with this method.
|
Decision Center API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |