Top Banner
Luc Bors, june 2013, ODTUG KScope 2013 New Orleans Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces Goodbye Nightmare
63

Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Jan 22, 2015

Download

Technology

One of the most challenging tasks when developing an ADF application is achieving a proper layout. Both
stretching components and the ones that don't stretch can make a developer's life into a nightmare. In this
session you will learn best practices for creating complex layouts with ADF Faces. You will see how to use the
various ADF Layout components and build the layout that you need.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Luc Bors, june 2013, ODTUG KScope 2013 New Orleans

Tips and Tricks for Creating Complex

Layouts with Oracle ADF Faces

Goodbye Nightmare

Page 2: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Who Am I

• Luc Bors

• Principal Consultant

• AMIS Nieuwegein Netherlands

• Friends of Oracle & Java

• 5 Oracle ACE(D)

• Oracle Partner

Page 3: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Just a Quote…

Let's face it: With ADF Faces rich client, layout ……..

once you are a layout master, all bow before you, but it's more of an art than a

science, and it is often, in fact, way too difficult to achieve what should

(apparently) be a pretty simple.

Page 4: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Back to the drawingboard

Page 5: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Visio Stencils

• http://www.oracle.com/technetwork/indexes/samplecode/jdeveloper-adf-sample-522118.html

Page 6: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

ADF Layout Containers

Page 7: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The PanelFormLayout

• Organize (input) components in a form layout

– Aligning labels and fields in

rows and columns

– attribute labelAlignment to

display labels above the fields

Page 8: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The PanelFormLayout

• Use the ‘Rows’ attribute

• Use the ‘MaxColumns’ attribute

Page 9: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The PanelStretchLayout

• Stretches its components to fill available space

– Top and bottom facet can be set to fixed height (or auto)

– Start and end facet can be set to fixed width

– Facets with no content

do not render

Page 10: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Demo

Page 11: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The PanelSplitter

• To create resizable panes

– That stretch their content

• panelSplitter has two facets: first and second

– Content for the panes is

provided in the facets

• Orientation horizontal or vertical

• Can be collapsible

• Position can be fixed

• Can be nested

• Collapse and resize events can be listened to

Page 12: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

panelAccordion

• The panelAccordion displays one or more collapsible/expandable panes in a vertically layout

– Multiple panes can be expanded at once if discloseMany=true• discloseNone=true means

that all panes can be

collapsed

– Overflow icon is shown

to scroll to panes that

do not fit in the area

– Expanding & Collapsing

panes is a client side

operation

– Accordions can be nested

Page 13: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

PanelTabbedLayout

• The panelTabbed displays one or more tabbed panes

– panelTabbed has position attribute

(tab can be shown at the top,

at the bottom or both)

• The content of a tab pane is in a showDetailItem

– A tab has attributes for title, icon, disabled,

• panelTabbed can be nested

• Overflow icon and popup are shown when the tabs do not fit next to each other

Page 14: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Flowing and Stretching

• Setting Background color can help youunderstand what is actually happening.

• Makes you recognize the components at runtime

Page 15: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Demo

Page 16: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Be Aware !!

Stretchable ? Stretches ?

PanelStretchLayout YES YES

PanelSplitter YES YES

PanelCollection YES YES

PanelGroupLayout

(scroll, vertital)

YES NO

PanelGroupLayout

(default, horizontal)

NO NO

PanelFromLayout NO NO

PanelBorderLayout NO NO

PanelDashBoard YES YES(Inside a grid)

PanelTabbed YES YES(StretchChildren = first)

Page 17: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

JDeveloper Can Help You

Page 18: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Quick Start Layouts

Page 19: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Predefined Layouts

Page 20: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors
Page 21: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Even better…

Page 22: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Colors rule !

Page 23: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The ADF Table

• Layout and the ADF Table

– How

– What

– When

Page 24: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

A Common ADF Layout issue

• PanelGroupLayout does not Stretch it’schildren

Page 25: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Solution

• Remove PGL

– This does the trick

• Surround withPanelCollection

– Very convenient

Page 26: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The (almost) stretched table

Page 27: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Using the column

• Consider Column Stretching– none (default): Gives optimal performance

– blank: Inserts an empty blank column that is stretched; use this so that the row’s

background colors will span the entire width of the table

– last: Stretches the last column to fill up any unused space inside the viewport

– column:<id>: Stretches a specified column; use the ID of the column that you want

to stretch (requires that you explicitly set the column’s ID property—the drop-down

list for the property displays all columns whose ID has been set)

– multiple When the "multiple" option is used you can set the widths in the columns

(non-group) to be percentages.

Page 28: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The stretched table

Page 29: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Demo

Page 30: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Ready ?

Page 31: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

ScrollBar ScrollBar Everywhere

• Never place a scrolling

panelGroupLayout inside of another

scrolling panelGroupLayout since

users do not like nested scroll bars

Page 32: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

And now they are gone ….

• I Know what to do:

Lets use layout vertical

on the outer PGL………

…… and they are all gone….

Page 33: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

This works best

• You learned earlier that:

– PanelGroupLayout does not Stretch it’s children

• Remove PGL

• Stretch via Styleclass

– AfStretchWidth

Page 34: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Now What …..

Page 35: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The PanelformLayout

• Can we create a properly aligned form ?

• Having alignment of fields on the left ?

• Having alignment of fields on the right ?

• Having First Name and Last Name in one line ?

• Look at the default layout for such a form…….

Page 36: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Step 1

• Bring First Name and Last Name into an aggregate Container

– use a panelLabelAndMessage component which is designed specifically for this

purpose of allowing several logical components, or components without their own

label property to be correctly laid out in a panelFormLayout.

Page 37: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Step 2

• Alignment Components For First Name and Last Name

– By default, the panelLabelAndMessage will lay out its children vertically. In this case

we want the components side-by-side. So simply use a horizontal panelGroupLayout

to align the two fields

Page 38: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Step 3 ?

• Remove Labels

Page 39: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Step 3 !

• Remove Labels

– The label is defined by the panelLabelAndMessage.

– set the simple property to “true” on each of the child components.

– also set the for property on the parent panelLabelAndMessage to the relevant child

component id. This will endure that error messages are correctly displayed.

Page 40: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Step 4

• Ensure Right Alignment

– Components such as the selectOneChoice do not stretch and are controlled by the

size of their data

– You will have to control the size manually using styles.

– The contentStyle property is used to control just the width of the drop down box itself

and therefore is the property to use. Unfortunately getting the exact width, is a matter

of trial and error.

– For precise alignment that can survive zooming by the user, you may have to set

explicit sizes in em’s for all the components in the form, or use the fieldWidth and

LabelWidth properties of the panelFormLayout.

Page 41: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

And Finally……The Result

Page 42: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Separators and Spacers

• Default behavior • Spacers and Separators

Page 43: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Now What …..

Page 44: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Forget (almost) all Of the Above….

Page 45: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

The PanelGridLayout

• The panelGridLayout component is a layout container component that

– uses one or more gridRow components to describe the rows of a grid layout

structure.

– Each row defines a height and margins.

– Each gridRow uses one or more gridCell components to describe the cells for

columns in that row of the grid layout structure.

– Each cell defines width, margins, column span, row span, horizontal alignment, and

vertical alignment

Page 46: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

How does it work ?

Page 47: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Bye Bye Spacers & Separators

Page 48: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors
Page 49: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

How to make this layout ?

Page 50: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

How we Used to do it

Page 51: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

This is What we do Now

Page 52: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Creating OTN with ADF

Page 53: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Demo

Page 54: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

What about Outlook ?

Page 55: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Demo

Page 56: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Outlook in ADF

Page 57: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Summary tips

• Work with colors

– Makes it clear what is going on

• Use as little layout containers as possible.

– The pages is smaller and faster

• Reduce the number of components that need to stretch

– The pages are faster

• Use the quick start layouts

– Saves you time

Page 58: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Summary tips

• Start with strechtable outer frame

– Such as…PSL, PSP,

• In there, have the flowing islands.

• Never try to stretch something vertically in a flowing island

– Inconsistent results accross browsers

– Also need to consider the case where you build pagefragments that can be reused in

other pages.

– Styling only via Styleclass.

• Use the Developerguide or create your own Cheat Sheet !

• Benefit from PanelGridLayout !!!

– 11.1.1.7 or 11.1.2.2+

Page 59: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

And do not ….

• Do Not use RAW HTML in the pages

• Do Not use inlinestyle � use skinning

• Do Not specify height with %

– Might result in multiple vertical scrollbars

• Do not try to stretch a none stretchable component by setting width = 100%

– Surround with stretchable componenent that also stretches its children

– Or use AFStretchWidth styleClass

Page 60: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Resources

• http://www.oracle.com/webfolder/ux/middleware/richclient/index.html

Page 61: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Resources

• http://jdevadf.oracle.com/faces11117/faces/index.jspx

Page 62: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Questions ….. Answers….

Page 63: Goodbye Nightmare: Tips and Tricks for Creating Complex Layouts with Oracle ADF Faces - Luc Bors

Luc Bors, AMIS, The Netherlands

[email protected]

[email protected]

Follow me on : @lucb_