Working on a project tonight, I wanted to have a control like the carousel, but without all the space wasting. I wanted an image, with some attribute values laid out in a table on top of the image, and I also wanted the left and right halves of the image to be active to navigate through my collection executing the Next and Previous bindings. I added a dashed-red border to show the areas that respond to user input.
I wanted to leverage the standard rendering, but style the resulting DOM to fit my tastes. My page consists of an image followed by two tables, the first contains text overlays, the second contains buttons.
<amx:panelGroupLayout id="pgl1">
<amx:image id="i1" source="#{pageFlowScope.img}" styleClass="overlay-image"/>
<amx:tableLayout id="txtOvr" styleClass="overlay" width="100%">
<amx:rowLayout id="rl1">
<amx:cellFormat id="cf1" valign="top" height="100px">
<amx:outputText value="outputText1" id="ot2"/>
</amx:cellFormat>
<amx:cellFormat id="cf2" halign="end" valign="top">
<amx:outputText value="outputText2" id="ot3"/>
</amx:cellFormat>
</amx:rowLayout>
<amx:rowLayout id="rl2">
<amx:cellFormat id="cf3" valign="bottom" height="33px">
<amx:outputText value="outputText3" id="ot4"/>
</amx:cellFormat>
<amx:cellFormat id="cf4" valign="bottom" halign="end">
<amx:outputText value="outputText4" id="ot5"/>
</amx:cellFormat>
</amx:rowLayout>
</amx:tableLayout>
<amx:tableLayout id="actionOvr" styleClass="overlay" width="100%">
<amx:rowLayout id="rl3">
<amx:cellFormat id="cf5" width="50%" height="133px">
<amx:commandButton id="cb1" styleClass="prev" action="#{bindings.Previous.execute}"/>
</amx:cellFormat>
<amx:cellFormat id="cf6" width="50%">
<amx:commandButton id="cb2" styleClass="next" action="#{bindings.Next.execute}"/>
</amx:cellFormat>
</amx:rowLayout>
</amx:tableLayout>
</amx:panelGroupLayout>
Without styling, the above page would lay out the image and two tables vertically. By adding the skin below, it results in a nice data/navigationMenu overlay.
.overlay-image,
.overlay,
.overlay .amx-commandButton {
display: block; /*normally not cool, but these are pretty specific selectors */
height: 133px;
width: 100%;
border-radius: 0;
}
.overlay {
position: absolute; /*usually bad news, but this is a specific target */
top: -133px;
}
.overlay .amx-commandButton {
background-image: none;
opacity: 0.7;
width: 90%;
height: 120px;
/* left this visible for demonstration purposes, normally set to none */
border: 1px dashed red;
}
.overlay .amx-outputText {
color: white;
text-shadow: 2px 1px 0px black;
font-size: 24px;
}
.amx-commandButton.next {
background-image: url('../icons/next.png');
background-position: center right;
background-repeat: no-repeat;
}
.amx-commandButton.prev {
background-image: url('../icons/prev.png');
background-position: center left;
background-repeat: no-repeat;
}
We could also just put a single big button over the top of the image with swipeLeft/Right setActionListeners, or make the swipe button in the middle with the push buttons made narrower.