jsf2 tomahawk selectOneRadio render label separately - jsf-2

I am using Tomahawk radio control for my design requirement. I was testing and wanted to ask if someone answer please.
<t:selectOneRadio id="myRadio" forceId="true" layout="spread" styleClass="field checkbox">
<f:selectItems value="#{personBean.genders}" />
</t:selectOneRadio>
<c:forEach items="#{personBean.genders}" varStatus="loop">
<span style="width:80px;" class="checkbox"><t:radio for=":myForm:myRadio" index="#{loop.index}" /></span>
</c:forEach>
HTML Generated
<span class="checkbox"><input type="radio" class="field checkbox" value="male" name="myRadio" id="myForm:j_idt35"><label for="myForm:j_idt35"> male</label></span>
Question:
I want to use class attribute on male which is rendered with the checkbox. Is it possible to render it separately?
I can apply style like below but I want Label to render separately to have more control.
.checkbox label {
display: block;
cursor: pointer;
font-size: 100%;
line-height: 150%;
margin: -17px 0 0 18px;
padding: 0 0 5px 0;
color: #222;
width: 88%
}

Looking at the source code no, it's not.
You could however style it with +:
input[type='checkbox'] + label {
display: block;
cursor: pointer;
font-size: 100%;
line-height: 150%;
margin: -17px 0 0 18px;
padding: 0 0 5px 0;
color: #222;
width: 88%
}
If would like to render it differently, you need to override HtmlRadioRenderer:
Put this in faces-config.xml:
<renderer>
<component-family>javax.faces.SelectOne</component-family>
<renderer-type>org.apache.myfaces.Radio</renderer-type>
<renderer-class>your-renderer-class</renderer-class>
</renderer>
Create a class your-renderer-class.java, override in in org.apache.myfaces.renderkit.html.ext.HtmlRadioRenderer and you are good to go.
Read the web on how this is done: JSF 2.0: How to override base renderers with custom ones?

Related

Angular Mat-List-Option Layout Changes When Using CDK Drag and Drop

I am developing an Angular 7 web application and am struggling with a Mat-Selection-List where I allow the user to drag and drop the mat-list-option items.
Each mat-list-option item comprises a div which uses Flex Layout to arrange its components as follows:
<mat-selection-list #taskGroupSelectionList
cdkDropList
[(ngModel)]="selectedOptions"
(ngModelChange)="onNgModelChange($event)"
(selectionChange)="onSelectionChange($event)"
class="task-group-list"
(cdkDropListDropped)="drop($event)">
<mat-list-option class="task-group-box" checkboxPosition="after" *ngFor="let taskGroup of taskGroups" [value]="taskGroup" cdkDrag>
<!-- Task Group Item -->
<div fxLayout="row" *ngIf="taskGroup" fxLayoutAlign="start center" style="width: 100%; height: 100%;">
<!-- Move Handle -->
<div fxFlex="32px" style="padding: 0 0 0 4px;">
<mat-icon class="summary-channel-handle">menu</mat-icon>
</div>
<!-- Index -->
<div fxFlex="24px;">
<p style="margin: 0; text-align: right;">
{{taskGroup.orderId}}:
</p>
</div>
<!-- Title -->
<div fxFlex="nogrow">
<p style="margin: 0; padding: 0 0 0 8px; text-overflow: ellipsis; white-space: nowrap;">
{{taskGroup.title}}
</p>
</div>
</div>
</mat-list-option>
</mat-selection-list>
The key CSS styles for this simple component are as follows:
.task-group-list {
width: 100%;
height: 100%;
display: block;
background: white;
}
.task-group-box {
border-left: solid 1px #ddd;
border-right: solid 1px #ddd;
border-bottom: solid 1px #ddd;
border-radius: 4px;
height: 48px;
color: rgba(0, 0, 0, 0.87);
box-sizing: border-box;
cursor: move;
background: white;
}
.task-group-box:first-child {
border: solid 1px #ddd;
}
.task-group-list.cdk-drop-list-dragging .task-group-box:not(.cdk-drag-placeholder) {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
.cdk-drag-preview {
box-sizing: border-box;
border-radius: 4px;
height: 48px;
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.cdk-drag-placeholder {
box-sizing: border-box;
border-radius: 4px;
height: 48px;
opacity: 0;
}
.cdk-drag-animating {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
Functionally I can drag and drop the list items, however when dragging, the mat-list-option checkbox which I have placed on the right checkboxPosition="after" moves to the top left corner and pushes the elements of the mat-list-option down.
Does anyone know why the layout changes on dragging please?
The element being dragged can be found as the last child of body in the DOM (only on drag), and this creates quite some problems as you can read here.
If your mat-list-option element is not very complex, only the checkbox and some text, you can solve this by adding some CSS to the global styles.css file, for example:
/* Checkbox and text inline and vertically centered */
.cdk-drag-preview .mat-list-item-content {
display: flex;
align-items: center;
}
/* Checkbox margin from text */
.cdk-drag-preview .mat-pseudo-checkbox {
margin-right: 10px;
}
You can see a DEMO in this stackblitz that I created.
If the content of your mat-list-option element is a bit more complex you will need to inspect the element and add the necessary styles. You can do this by dragging the mat-list-option and right clicking while dragging, inspect element and find classes that you can use to style it.
A better alternative might be to just create a custom cdkDragPreview. You can style this as you wish.
<mat-selection-list #movies cdkDropList>
<mat-list-option *ngFor="let movie of movies" cdkDrag>
{{movie}}
<ng-template cdkDragPreview [matchSize]="true">
<div class="movie-preview">
{{ movie }}
</div>
</ng-template>
</mat-list-option>
</mat-selection-list>
Important: The matchSize input is required to automatically size the item being dragged.
And since the css is scoped to your component, even when it's moved outside the DOM tree of your component it retains the style (assuming Emulated style encapsulation).
.movie-preview
{
line-height: 3;
padding: 0 1em;
color: hotpink;
background: white;
/* border (and hotpink color) are optional, based on your preference */
border: 1px solid #ccc;
border-radius: .5em;
}
That looks like this when dragging:
Try with ::ng-deep
::ng-deep .cdk-drag-preview .mat-list-item-content{
display: flex;
flex-direction: row;
align-items: center;
box-sizing: border-box;
padding: 0 16px;
position: relative;
height: inherit;
}
this works for me

css input number field rendering weird on certain versions of ios

The input number field doesn't render properly on ios. The number gets cut off at the bottom. It works for certain ios versions but not other ones. I'm stuck, please help
input[type=submit] {
text-align: center;
}
.page_q3 input[type="number"] {
height: 91px;
width: 110px;
color: #464356;
font-family: "Source Sans Pro";
font-size: 82px;
font-weight: 600;
text-align: center;
border: none;
border-bottom: 2px solid #464356;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
<div class="page_q3">
<div class="div_minus"><img src="<?=$templateDir?>/images/minus.jpg" class="minus" data-quantity="minus" data-field="<?=$inputName?>" /> </div>
<div class="div_number"><input type="number" id="<?=$inputName ?>" name="<?=$inputName?>" value="<?=$_SESSION[$inputName]?>" placeholder="0" /> </div>
<div class="div_plus"><img src="<?=$templateDir?>/images/plus.jpg"
class="plus" data-quantity="plus" data-field="<?=$inputName?>" /> </div>
</div>
What it should look like
https://ibb.co/y8msSpL
what it actually looks like
https://ibb.co/rkbyPF5
You might want to try removing the border-radius and padding that are added by iOS by default:
.page_q3 input[type="number"] {
-webkit-border-radius: 0;
border-radius: 0;
padding: 0;
}

Phonegapp CSS issue

I have some issues with my Phonegap app concerning the UI. When I view it in my Desktop browser it looks like this(the way it shoul be):
But when I implement it in Phonegap (on iOS) it looks like this:
This is my html:
<div id="page1">
<div id="formScales">
<div class="formContent" id="noise">
<p>Noise</p>
<input type="button" id="nbtn1" value="Noisy" />
<input type="button" id="nbtn2" value="Medium noisy" />
<input class="active" type="button" id="nbtn3" value="Neutral" />
</div>
[...]
</div>
And the CSS:
[...]
#formScales {
position: relative;
/* otherwise the float of the child gets it out
of the document flow */
overflow:auto;
}
input {
color: #3B444B;
width: 100%;
text-decoration: none;
text-align: center;
padding: 8px 12px;
margin-top: 5px;
font-size: 12px;
font-weight: 700;
font-family: helvetica, arial, sans-serif;
border-radius: 2px;
border: 1px solid #606060;
background-color: rgba(255,255,255, 0.8);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.12);
box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.active {
background-color: #99CCFF !important;
border: 1px solid #606060;
}
#noise {
float: left;
width: 31vw;
margin-left: 5px;
margin-right: 5px;
margin-bottom: 7px;
background-color: rgba(255, 204, 204, 0.3);
}
My guess is that it has something to do with the Objective-C UIWebView class used by iOS... I would be happy about any advice on how to fix this - also what would be best to test the UI without always having to rebuild the PG app!
Thanks in advance!
adding "webkit-appearance:none" to input did the trick!
input {
/* webkit-appearance:none to override standard button design! */
-webkit-appearance: none;
[...]
}
Whether your page contents are overlapping on status bar of i-phone? Actually I unable to see it in screenshot. If it is, then you can do this in your config.xml. I was having same issue, I solved it by adding these lines to config.xml
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#000000" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="ios-statusbarstyle" value="black-opaque" />
You can test UI on android emulator, without building app on PG-build, but this will not ensure you that you will get correct results for iOS also, I mean if you tested UI on android emulator, then it isn't guaranteed that it will work well on i-phone. So I will recommend you to use PG-build

jQuery Mobile forms combining input elements

When using jQuery mobile, is it possible to combine a checkbox or button with a text input? Something like in my image below.
I want to use it as field validation so it will turn red or green when user updates the field.
jQuery Mobile does not include this, but you can do it via CSS.
Here is a DEMO with a couple of options
The first uses a table, so the left button is always the same size and the input grows/shrinks on window resize. While the second option uses a div and bothe button and label grow shrink.
Fot the table, the css removes borders and spacing on the table and sets the first td width to a constant value. The rest of the css makes the button and input look right:
<table id="specialContTbl">
<tr>
<td class="btntd">
<button data-role="none" id="btn">B</button>
</td>
<td class="inptd">
<input data-role="none" type="text" id="inp1" name="inp1" value="" placeholder="enter some text" />
</td>
</tr>
</table>
#specialContTbl {
border-spacing: 0;
border-collapse: collapsed;
}
#specialContTbl td {
padding:0;
margin: 0;
border: 0;
vertical-align: top;
}
#specialContTbl td:first-child{
width: 60px;
}
#specialContTbl{
width: 100%;
}
#specialContTbl button, #specialContTbl input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#specialContTbl button {
font-weight: normal;
background: #00f050;
padding: 5px;
color: #333;
border: 1px solid #d4d4d4;
border-right: 0;
border-bottom-left-radius:1em;
border-top-left-radius: 1em;
line-height: 28px;
height: 38px;
width: 100%;
float: left;
text-align: center;
cursor: pointer;
white-space:nowrap;
}
#specialContTbl input {
width: 100%;
height: 38px;
padding: 8px;
border: 1px solid #d4d4d4;
border-bottom-right-radius: 1em;
border-top-right-radius: 1em;
line-height: 18px;
float: right;
box-shadow: inset 0px 2px 2px #ececec;
}
#specialContTbl input:focus {
outline: 0;
}

css3.0 - content attribute

I have written a css file
.atleastTwoChars:after {
content: "2*";
float: left;
width: 16px;
height: 14px;
border: 0;
margin: 2px 3px 0px 3px;
color: red;
}
I have used like this
<nobr>
<input type="hidden"
name="ctl00$objContentPageTag$spzContactInformation$txt_sContactZipCode$objHidden"
id="ctl00_objContentPageTag_spzContactInformation_txt_sContactZipCode_objHidden" value="0">
<input name="ctl00$objContentPageTag$spzContactInformation$txt_sContactZipCode$objTextBox"
type="text"
id="ctl00_objContentPageTag_spzContactInformation_txt_sContactZipCode_objTextBox"
class="xqh_LookUpTextBox_Edit">
<span id="ctl00_objContentPageTag_spzContactInformation_txt_sContactZipCode_spanImgMandatory"
class="atleastTwoChars">
</span>
</nobr>
JavaScript:
$('#ctl00_objContentPageTag_spzContactInformation_txt_sContactZipCode_spanImgMandatory')
.removeClass("xqh_LookUpTextBox_ImgMandatory")
.addClass("atleastTwoChars");
$('img[id*="txt_sContactZipCode_imgMandatory"]').remove();
problem: content (2*) should be displayed at the end of the text box but it is displaying at the start like this.
Remove the float: right; from your CSS: JS Fiddle demo.
Incidentally, according to W3, nobr:
[...is] entirely obsolete, and must not be used by authors...
Reference:
Obsolete features, at the W3.org
The float: left; will make it display at the start of the line. Perhaps you want to use display: inline-block; instead. Or just remove the float, height and width.

Resources