TWiki
>
WebXEO Web
>
XeoPrimer
>
XeoPrimerWebComponentsAPI
(revision 3) (raw view)
Edit
Attach
Tags:
tag this topic
create new tag
,
view all tags
-- Main.PedroRio - 18 Feb 2011 ---+ XEO Web Components - Samples. This section has snippets of code to perform a certain operation (and explanation of the snippet) ---++++++ Opening a new viewer A fairly common operation will be opening a viewer in response to a user clicking a button or something similar. To do so, in the bean method where you want to open the viewer use the following code: *XML Definition* <pre><verbatim><xvw:menu text='Open Tab' target='tab' serverAction='#{viewBean.openTab}'></verbatim> </pre> *Java Code* <verbatim>public void openTab(){ //Create a XUIViewRoot representing the viewer (viewer can be located in the source code, or in the webapp of the application) XUIViewRoot viewRoot = getSessionContext().createChildView("viewers/path/to/viewer/Viewer.xvw"); //Set the newly created viewroot as the view root of the request getRequestContext().setViewRoot(viewRoot); //Render the response getRequestContext().renderResponse(); }</verbatim> _ ---++++++ Opening a new viewer (in a window) Sometimes you'll want to open a viewer inside a small window (and not in a new tab). To do that you must add the xvw:window component to your viewer, and execute the same code as the previous example. *Viewer Definition* <verbatim><xvw:viewer beanClass="org.xeoframework.examples.MyBean" beanId="viewBean"> <xeo:formEdit> <xvw:window width='500' height='300'> <!-- Remaining components --> </xvw:window> </xeo:formEdit> </xvw:viewer></verbatim> *Menu (important, notice the absence of the "target" property, which defaults to "self")* <pre><verbatim><xvw:menu text='Open Window' serverAction='#{viewBean.openWindow}'> </verbatim> </pre> <strong>Java Code (same code as above, only change needed to be done for this example is adding the xvw:window component and removing the target property)<br /></strong> <verbatim>XUIViewRoot viewRoot = getSessionContext().createChildView("viewers/Objecto/MyViewer.xvw"); getRequestContext().setViewRoot(viewRoot); getRequestContext().renderResponse();</verbatim> _ ---++++++ Finding the selected line in a panel (gridpanel, list, bridge) A popular programming task with XEO Web Components is to have a gridPanel component (or list/bridge) and have toolbar with a button that will trigger some action on a selected line from the panel. To do that you need the following code in the method invoked by the button. <verbatim>Required public void processLine(){ //Find the GridPanel that has the selected line GridPanel panel = (GridPanel) getViewRoot().findComponent(GridPanel.class); //Retrieve the current active row (a DataRecordConnecor) DataRecordConnector currentLine = panel.getActiveRow(); //Find the column that has a meaningful value (i.e. and id, for example) DataFieldConnector currentColumn = currentLine.getAttribute("BOUI"); //Retrieve the value for that column String value = currentColumn.getValue().toString(); //Use the value of the BOUI to load and process the instance try { XEOApplication app = XEOApplication.getDefaultApplication(); boObject b = app.getSecureObjectManager(). loadObject(getEboContext(), Long.valueOf(value)); //Process the instance b.update(); } catch (boRuntimeException e) { /* Log or deal with the exception*/} }</verbatim> You may need a few modifications if: 1 You have more than one instance of a gridPanel/list/bridge component in your viewer 1 If you allow multiple lines to be selected and want to process them all If you fall in situation 1, you'll need to do the following: * Add an identifier to your form component (in the viewer) * Add an identifier to your gridPanel/list/bridge * Use a different find component method ---++++++ Changing the current active tab aaa Refreshing a list after closing a tab Component Plugins?
Edit
|
Attach
|
P
rint version
|
H
istory
:
r9
|
r5
<
r4
<
r3
<
r2
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r3 - 2011-02-18
-
PedroRio
WebXEO
XEO Primer
-
Instalation
-
Introduction
-
Concepts
-
Architecture
-
XEO Library
-
Deploy to EAR
-
PreferenceStore
XEO - Core
-
XEO Model Reference
-
Security
-
Java API
-
BOL
-
XEOQL (BOQL)
-
Administrating
-
Background Tasks
-
boConfig.xml
-
Web.xml
-
Known Issues
-
XEO Flags
XEO - XWC
- Web Components
- Java Samples
- Custom Components
- Component Plugins
- Internationalization
- Viewer Events
- Value Change Listeners
- XUIServlet
- XeoLocalization
- XvwTemplates
Create New Topic
WebXEO Web
No permission to view
TWiki.WebTopBar
No permission to view
TWiki.WebBottomBar