Licensed to the Apache Software Foundation (ASF) under one or more

contributor license agreements. See the NOTICE file distributed with

this work for additional information regarding copyright ownership.

The ASF licenses this file to You under the Apache License, Version 2.0

(the “License”); you may not use this file except in compliance with

the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an “AS IS” BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

layout: docpage title: Jewel ResponsiveView description: The Jewel ResponsiveView permalink: /component-sets/jewel/responsiveview

< Jewel Components list

Jewel ResponsiveView

Reference

Available since version 0.9.4.

ClassExtends
org.apache.royale.jewel.ResponsiveView{:target=‘_blank’}View{:target=‘_blank’}

Note: This component is currently only available for JavaScript.

Overview

ResponsiveView is the class used as the initialView in a responsive Royale Jewel Application. It is generally used as the root tag of MXML documents, and UI controls and containers are added to it.

It normaly can host a TopAppBar, FooterBar, Drawer and a ApplicationMainContent with other organized content for navigation.

For non-responsive applications you can use just a simple View instead.

Example of use

In MXML declare a ResponsiveView like this:

<j:ResponsiveView xmlns:fx="http://ns.adobe.com/mxml/2009" 
	xmlns:j="library://ns.apache.org/royale/jewel">

    <!-- ResponsiveView code goes here -->
</j:ResponsiveView>

ResponsiveView doesn't need to specify width or height since they are both sized 100% by default. In this way we can use the width of the application container to apply responsive rules on any part of the application.

You can also set the ResponsiveView directly in the application mxml file inside the initialView:

<j:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
	xmlns:j="library://ns.apache.org/royale/jewel">
	...
	<j:initialView>
		<j:ResponsiveView>
			<!-- ResponsiveView code goes here -->
		</j:ResponsiveView>
	</j:initialView>
</j:Application>

In ActionScript we can do the same in the following way:

// instantiate the view
var responsiveView:ResponsiveView = new ResponsiveView();
// add content to the view and and add to application's initialView
application.initialView = responsiveView;

where application is the Jewel Application.

Relevant Properties and Methods

Check the Reference of org.apache.royale.jewel.ResponsiveView{:target=‘_blank’} for a more detailed list of properties and methods.

Properties

PROPERTYTypeDescription
applicationModelObjectA reference to the Application's model.
currentStateStringThe name of the current state.
numElementsintThe number of element children that can be laid out.
mxmlContentArrayThe array of childs for this view. Is the DefaultProperty.
popUpParentIPopUpHostParentA view can be the parent of a popup that will be part of the layout.
popUpHostIPopUpHostA view can host popups that will be part of the layout.
statesArrayThe array of view states. These should be instances of org.apache.royale.states.State{:target=‘_blank’}

Methods

MethodParametersDescription
addElementc(IChild), dispatchEvent(Boolean=true)Add a component to the parent.
addElementAtc(IChild), index(int), dispatchEvent(Boolean=true)Add a component to the parent at the specified index.
getElementIndexc(IChild)Gets the index of this subcomponent.
getElementAtindex(int)Get a component from the parent at specified index.
removeElementc(IChild), dispatchEvent(Boolean=true)Remove a component from the parent.

Relevant Events

The most important event is initComplete, which indicates that initialization of the view is complete.

It is needed when some action coded in a callback function needs to be triggered when the view is ready to use after initialization.

You can attach callback listeners to the initComplete event in MXML as follows:

<j:ResponsiveView initComplete="initCompleteHandler(event)"/>

the initComplete event will use the initCompleteHandler callback function you provide in ActionScript:

<fx:Script>
    <![CDATA[      
        private function initCompleteHandler(event:Event):void {
            trace("ResponsiveView is ready!");
        }
    ]]>
</fx:Script>

When the view is initialized the message “ResponsiveView is ready!” appears in the console log.

In ActionScript we can add an event handler this way:

var rv:ResponsiveView = new ResponsiveView();
rv.addEventListener('initComplete', initCompleteHandler);

Relevant Beads

Bead TypeImplementationDescription
GroupView{:target=‘_blank’}org.apache.royale.core.IBeadView{:target=‘_blank’}This is the default view bead.
ViewLayout{:target=‘_blank’}org.apache.royale.core.IBeadLayout{:target=‘_blank’}This is the default layout bead.

Optional Beads

Bead TypeImplementationDescription
ViewDataBinding{:target=‘_blank’}org.apache.royale.binding.DataBindingBase{:target=‘_blank’}Provide binding capabilities to the view.

More examples

Related controls

Other useful Jewel view components are: