Flex 4: Checkbox in Accordion header - apache-flex

I wanted to know if it is possible to add a checkbox in the accordion control.
The main idea is to have a list of selectable items (like selecting various items for checkout) and each of them should have an option to display additional information (the accordion panel).
So basically, 3 questions:
Can I have a checkbox in the accordion header?
Can I have all the panels closed from the start? So the user chooses which panel to open, and not start with one panel displayed.
Can I have multiple panels opened at the same time?
Some notes:
- I tried a header renderer option, but the checkbox was the same for all accordion headers, so it was useless.
- It would be great to avoid the use of libraries or external controls. I am aware of some of the limitations of Flex controls though.
Thanks for any help or information you can provide ! :)

If you're not dead set on using mx controls, I'd give the 4.6 list/item renderer skinning method a try.
I'd use the sparks list control and create a custom item render that's comprised of checkbox control, several nested group/border-container wrappers depending on your design/creative requirements and whatever as3 logic would be necessary to expand and contract the item renderer keyed off of the checkbox's click event or change events-- that's some of the beauty of skinning item renderers in flex 4, you can encapsulate all that dope-ass logic within renderer itself.
In any case, here's some links you might find helpful:
http://www.adobe.com/devnet/flex/articles/flex4_skinning.html
http://blog.flexexamples.com/2009/06/21/creating-a-custom-halo-accordion-header-skin-in-flex-4/
http://saturnboy.com/2009/09/flex4-component-states-skin-states/
hope this helps!

Related

Adobe CQ Components restricting child components

I am trying to create a component for a simple accordion, where blocks of content are held under headings and only one heading is visible at a time. My preferred implementation uses two components, one to represent the whole accordion and a second component for a single entry.
The idea is that a content author can pull the accordion in from the sidekick, then drop one or more accordion items into the accordion, but not allow any other components to be dropped here. The accordion items should only be able to be dropped into the accordion component and not within any other parsys.
My problem is that currently it is possible to add other content into the accordion and add accordion items outside of the accordion.
The first attempt to solve this was:
foobar/components/accordion
foobar/components/accordion/accordion.jsp
foobar/components/accordion/cq:editConfig
foobar/components/accordion/dialog
foobar/components/accordion/accordionitem
foobar/components/accordion/accordionitem/accordionitem.jsp
foobar/components/accordion/accordionitem/cq:editConfig
foobar/components/accordion/accordionitem/dialog
These are the config files from this are:
accordion/.content.xml
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:isContainer="{Boolean}true"
jcr:primaryType="cq:Component"
jcr:title="Accordion"
sling:resourceSuperType="foundation/components/parbase"
allowedChildren="[*/accordion/accordionitem]"
allowedParents="[*/parsys]"
componentGroup="General"/>
accordion/_cq_editConfig.xml
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:actions="[-,edit,-,delete]"
cq:layout="editbar"
jcr:primaryType="cq:EditConfig">
<cq:listeners
jcr:primaryType="cq:EditListenersConfig"
aftercopy="REFRESH_PAGE"
afterdelete="REFRESH_PAGE"
afterinsert="REFRESH_PAGE"/>
</jcr:root>
The dialog is blank and exists only so that the component will appear in the sidekick.
accordion.jsp simply includes the foundation parsys.
accordion/accordionitem/.content.xml
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"
jcr:title="Accordion Item"
sling:resourceSuperType="foundation/components/parbase"
allowedParents="[*/accordion]"
componentGroup="General"/>
The accordion item dialog takes in the title. The editConfig simply adds the toolbar, but no listeners.
accordionitem.jsp outputs the title taken from the dialog and has a parsys.
My problem seems to be that the parsys aren't using the rules for the accordion and accordionitem components. Instead they seem to inherit from the next parsys up instead, unless overwritten.
I can set the components correctly by using edit mode on the page and selecting the appropriate components, but that sets the information against the template, meaning I need to perform the same configuration for every page template. What I want is to have it defined in the component definition instead so that it exists once.
After first writing the components I found this blog, which describes exactly the same scenerio: http://jenikya.com/blog/2012/03/cq5-accordion-component.html
Using that as I reference, I tried adding an extension of parsys to use within accordion.jsp instead. This made no difference to the code, so even my custom parsys allowed components other than accordion item to be added.
Any guidance on either what is wrong or other approaches to take will be greatly appreciated.
The solution here would be to use a parsys and build a composite component to restrict the accordion content to a set of components only (as described in the blog entry).
Have a look at http://localhost:4502/content/geometrixx/en/company/press/asseteditor.html which also uses this technique for the dam/components/asseteditor/thumbnail component.
This is a very generic problem statement in AEM. There are several ways to handle it, depends on your business need and how your design will map this. I can suggest two solution for this:
1. Apply Template level design restriction for your accordion component. Which means, you drop accordion component and then go to design mode of page and in accordion par select accordion item component. This is one time activity only.
Though i would recommend option #2:
2. In accordion component dialog, ask author to add accordion item using multilist.
- To add a new item, simply open accordion dialog and add item in multilist and enter accordion id in it.
- To remove item, open dialog and remove item from multilist
- To change position, rearrange items in multilist.
Based on no of multilist items entered by author in Accordion dialog, statically include accordion item component and give component id entered by author in multilist.
Using this approach, you will
- easily restrict component in accordion.
- Reduce one component (accordion item) in sidekick
- Reduce one parsys on page (so many parsys eat authoring performance)

Decorating item renderers in custom list components

Has anyone had success creating a custom list component which accepts a user defined item renderer, but decorates it with another class to augment its behavior?
Examples of why this might be useful include:
catching and stopping the propagation of events or dispatching new events in place of others
incorporating behavior in the renderer to interface with other packages used by the custom component
adding expand and collapse buttons for resizing the internal renderer, etc
The idea here is to not require changing the users renderer to work with this component, so keep that in mind.
Yep, I did this with the Flextras DataSorter. The DataSorter is a customized list that acts like a Netflix Movie Queue. The user's itemRenderer contains their stuff, but our wrapper adds in the number input field, the move up button, the move down button, and the other button controls.
It is pretty much a nightmare that required a lot of heavy customization of the Flex List class.
Since you're question is a "Yes" or "No" question, I feel I've answered it. What else did you want to know?

How do I create a "closed" Flex Accordian control?

I'm trying to create a navigation panel based on the Flex Accordion control. The 2 things I'm trying to figure out are how to:
modify the Accordion so that all of the of "panels" are closed by default. (normally one of the panels is open by default)
treat some of the Accordian headers as just simple buttons (ie you click and an event is triggered instead of an accordion panel opening)
Does anyone have any pointers on implementing these 2 items or know of any existing components that could yield this behavior?
Thanks!
Flexlib has CanvasButtonAccordionHeader, which would help implement the button functionality.
This SO question suggests starting with flexlib's WindowShade component instead, which might make the "none-selected" case easier.

Advanced DataGrid Flex 3 - ItemRenderer and Tree display

I am using Advanced DataGrid of Flex 3 with hierarchical data. The itemRenderer is a TextInput which accepts numbers. When I enter data into the given field and click the corresponding expand tree icon for the row, I want the amount entered in tree node should get cascaded to its child rows. But I found the nature of advanced DataGrid erroneous.
When I enter data and click on tree icon, the data is not populated in child windows unless i wont take the focus out from the editing control.
I tried using itemEditEnd, itemFocusOut etc but of no use. I have to explicitly click on any of the other columns and then expand tree.
Am I making any mistake anywhere?
I found solution to my problem, its bit ugly but it works. I had to register two events for textinput as follows
addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, allocateAmount);
addEventListener(FocusEvent.KEY_FOCUS_CHANGE, allocateAmount);
and then by using IViewCursor I could able to update data.

Adobe Flex / as3: How to implement custom drag-and-drop cursors

Our product team has requested custom cursors during drag/drop operations. They have provided me with three images to implement:
Open-Hand-Grabber.png: displays when a user hovers over an item that they can drag
Closed-Hand-Grabber.png: item is being dragged
Closed-Hand-Grabber-No-Drop: item dragged over an area where it cannot be dropped
I have embedded these images into the Flex application and I am now trying to implement the desired behavior.
My first thought was to listen to the drag/drop events and set the cursors using the CursorManager.setCursor() method. This solution seems very code intensive and I feel that there must be an easier way to skin the various drag/drop cursor states.
Any ideas?
Check out the various cursor styles available on the DragManager class:
copyCursor
defaultDragImageSkin
linkCursor
moveCursor
rejectCursor
http://livedocs.adobe.com/flex/3/langref/mx/managers/DragManager.html

Resources