calendar in Primefaces Mobile - mobile

I am looking at picking a date in Primefaces Mobile with "calendar" component:
<p:calendar value="#{bean.date}" pattern="MM/dd/yyyy HH:mm" />
The calendar pops up but it looks very odd. It overlaps the page content in a transparent way.
Is there a work around for this issue? Or a way to get it pop up correctly inside a dialog? Maybe to combine another framework with Primefaces?
By the way, the dialog seems not to work too in Primefaces Mobile.
Thanks

Primefaces Mobile is really great and is still under development but it doesn't implement Jquery mobile extensions like "datebox". I find a way to combine both. I included the jquery-datebox library in the header of a JSF page (see link):
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pm="http://primefaces.prime.com.tr/mobile"
xmlns:p="http://primefaces.prime.com.tr/ui"
contentType="text/html">
<pm:page title="Faces">
<f:facet name="postinit">
<h:outputStylesheet library="css" name="jquery.mobile-1.0b3.min.css" />
<h:outputStylesheet library="css" name="jquery.mobile.datebox.min.css" />
<h:outputScript library="primefaces" name="mobile/mobile.js" />
<h:outputScript library="js" name="jquery.mobile.datebox.min.js" />
</f:facet>
<!-- Main View -->
<pm:view id="main" swatch="b">
<pm:header title="Hello">
<f:facet name="left">
<pm:button value="Back" icon="back" role="back"/>
</f:facet>
</pm:header>
<pm:content>
<h:form id="myform">
<h:outputText value="Input: " />
<h:inputText id="input" />
</h:form>
</pm:content>
<label for="mydate">Date: </label>
<input name="mydate" id="mydate" type="date" data-role="datebox" value="#{mybean.date}"
data-options='{"mode": "calbox"}' />
<div data-role="fieldcontain">
<label for="slider">Duration: </label>
<input type="range" name="slider" id="slider"
value="#{mybean.duration}" min="1" max="10" />
</div>
<pm:content>
<h:form id="Form">
<pm:field>
<h:outputLabel for="duration" value="duration: "/>
<pm:slider id="duration" min="1" max="10" value="#{mybean.duration}"/>
</pm:field>
</h:form>
</pm:content>
</pm:view>
</pm:page>
</f:view>
The datepicker works well but both sliders inside and outside a pm-view (see the code) are displayed like normal inputs!
Any suggestions? Thanks
PS: #administrator: a new tag is needed: "Primefaces-mobile"

Related

using ng-mask for phone

I still have doubt in using ng-mask, I went through most of the web pages for it to work but it still remains the same. And many people told to use it with input tag of angularjs, after doing so Im not able to mask the input.Or am I making mistake please somebody correct me and give the clarity of using the ng-mask.
<input type="tel" name="phoneno" maxlength=13 ng-model="phone.number" ng-mask="(999)999-9999"/>
</div>
<button class="button2" ng-click="home()">Back</button> &nbsp &nbsp &nbsp
<button class="button3" ng-click="addphone()">Add</button>
Download the ngMask.min.js from net
Call the ngMask.min.js before app.js and Include app.js module
var yourApp= angular.module("yourApp", [
'ngMask'
]);
HTML :
<input type="tel" name="phoneno" maxlength=13 ng-model="phone.number" mask="(999)999-9999" />
Below code is working for me.
I think you should use data-on attribute like below
<input type="text" class="form-control input-small" data-ng-model="zipcode" placeholder="Enter the zip code" data-ng-mask="#####-###" data-on="keyup">
// 2. Add ngMask module dependency to your app.
angular.module('yourApp', ['ngMask']);
<!-- 1. Add ngMask plugin after your AngularJS. -->
<script src="angular.min.js"></script>
<script src='ngMask.min.js'></script>
<!-- 3. Use the avaiable patterns to create your mask. Set the mask attribute. -->
<input type='text' ng-model='maskModel' mask='39/19/9999' />
<!-- 4. Adjust your mask options. -->
<input type='text' ng-model='maskModel' ng-value='0/3/9' mask='3/9?' mask-repeat='2' mask-restrict='accept' mask-clean='true' mask-validate='false' mask-limit='false' />
source: https://github.com/candreoliveira/ngMask/blob/master/README.md
Use ui-mask instead:
<div class="form-group">
<label for="birth-date">Date of birth</label>
<input type="text"
class="form-control"
id="birth-date"
ng-model="formData.date_of_birth"
ng-value="formData.date_of_birth"
ui-mask="99.99.9999"
ui-mask-placeholder
ui-mask-placeholder-char="_"
>
</div>
https://github.com/angular-ui/ui-mask

paypal order summary empty on mobile

I couldn't find any similar questions (most dealt with broken form posts) but this is not the case.
I have a paypal form that works flawlessly on desktop/laptop. On mobile devices I successfully get to paypal but there is nothing in the order summary, as if nothing got posted to paypal. A variable dump shows all form variables are in place, so I'm quite confused.
Here is the form I submit:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="myRegister">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="service#obscured.com">
<input type="hidden" name="item_name" value="Some description.">
<input type="hidden" name="amount" value="5.00">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="item_number" value="1248" />
<input type="hidden" name="cbt" value="Click This Button To Register." />
<input type="hidden" name="return" value="http://mydomain/redirect.cfm" />
</form>
And that works on Desktop. I am just trying to get it work within a phone browser at the moment. I'll deal with the Paypal phone app at another time, if needed.
Any help appreciated.
Edit: This is also happening with PayPal hosted Buy It Now buttons as well.
Your code works fine for me on mobile, I can see the order details by tapping the "My total". The details are hidden at the first place though, I have to tap to make it show, seems it's designed this way
Within Android browser settings, clear setting for individual websites: Settings > Content Settings > Website Settings. Select paypal.com. Apparently there was a issue that was not resolved just by clearing the browser cache.

Angular form validation using the controllerAs syntax

I am currently facing the following problem:
I would like to validate my form input using the Angular ngModel directives.
When using those together with $scope they work fine.
Now, working with the controllerAs syntax, they fail to work.
This problem is poorly documented, the only help I could find is this article.
Here is a small example of my code:
The template gets called with myController as vm
<form name="vm.signUpForm" ng-submit="vm.signup(vm.user)">
<label for="name">Name</label>
<input type="text"
class="form-control"
id="name"
name="name"
placeholder="Full name"
ng-model="vm.user.name"
ng-minlength="2" required />
<div ng-show="vm.signUpForm.$submitted || vm.signUpForm.name.$touched">
<span ng-show="vm.signUpForm.name.$error.required">Please fill in your name</span>
<span ng-show="vm.signUpForm.name.$error.minlength">A minimum of 2 [...]</span>
</div>
[...]
</form>
Am I forced to use $scope to validate the form? Or did I miss something ?
Thanks in advance!
Solution by: Andrew Gray
I had to change the following lines to get this to work:
<form name="vm.signUpForm" ... >
<!-- To -->
<form name="signUpForm" ...>
<div ng-show="vm.signUpForm.$submitted || vm.signUpForm.name.$touched">
<!-- To -->
<div ng-if="signUpForm.name.$invalid">
<span ng-show="vm.signUpForm.name.$error.required" ... >
<!-- To -->
<span ng-show="signUpForm.name.$error.required" ... >
First things first - you don't need the vm. on the form.
<form novalidate name="someForm">
<label>
Some Text:
<span class="danger-text" ng-if="someForm.someText.$invalid">
ERROR!
</span>
</label>
<input type="text" name="someField" />
</form>
The way it winds up working, is that there's a validation object that is not tied to the scope. The controllerAs syntax is just spinning off a instance of the controller as a scope variable.
Try shaving off the vm. from the form and child elements' names, and you should be OK.

input file in ipad only let me choose pictures using ionic

i'm trying to attach documents to an item using an input file, works well in android i can choose a pdf file, but on the ipad only images can be selected.
is this a normal behaviour on ipad ?
<div ng-show="type.mode!=3">
<h3>Pièces jointes</h3>
<div class="uploader-buttons-container">
<!-- PDF uploader -->
<div class="custom-uploader">
<span>Ajouter <strong>PDF</strong></span>
<input type="file" class="upload" accept="application/pdf" onchange="angular.element(this).scope().pdf(this)" />
</div>
<!-- Image uploader -->
<div class="custom-uploader">
<span>Ajouter<i class="mini-symbol icon ion-image"></i></span>
<input type="file" class="upload" capture="camera" accept="image/*" onchange="angular.element(this).scope().photo(this)" />
</div>
</div>
You have
accept="image/*"
in input. Remove it and will be fine. It's not related to iPad.

AngularJS radio buttons not marked $dirty until last button selected

I created this simple example: http://jsfiddle.net/5Bh59/.
If you switch between AngularJS 1.2.1 and 1.1.1, you'll see the radio buttons don't work properly in either version. If you watch the radio button's $dirty field, 1) for version 1.1.1, it will only be set when the first button is clicked, and 2) for version 1.2.1, it will only be set when the last button is clicked.
I read this answer: AngularJS Radio group not setting $dirty on field but I don't really understand the answer. Not only that but the fiddler example demonstrates the same behavior.
So, is this a bug in AngularJS and how can I work around it?
You either need to give each radio button input a different name, or you need to wrap each radio button in an ng-form (each of which have a different name). If you use two inputs with the same name in the same form, only the last one will be bound to the property on the FormController. If you use different names, then each input will have its own property on the FormController.
Example with different names for each radio button:
http://jsfiddle.net/BEU3V/
<form name="form" novalidate>
<input type="radio"
name="myRadio1"
ng-model="myRadio"
ng-click=""
value="Rejected"
required>Rejected<br />
<input type="radio"
name="myRadio2"
ng-model="myRadio"
ng-click=""
value="Approved"
required>Approved<br />
Form $dirty: {{form.$dirty}}<br />
Field1 $dirty: {{form.myRadio1.$dirty}}<br />
Field1 $dirty: {{form.myRadio2.$dirty}}<br />
Value: {{myRadio}}
</form>
Example wrapping with ng-form:
http://jsfiddle.net/39Rrm/1/
<form name="form" novalidate>
<ng-form name="form1">
<input type="radio"
name="myRadio"
ng-model="myRadio"
ng-click=""
value="Rejected"
required>Rejected<br />
</ng-form>
<ng-form name="form2">
<input type="radio"
name="myRadio"
ng-model="myRadio"
ng-click=""
value="Approved"
required>Approved<br />
</ng-form>
Form $dirty: {{form.$dirty}}<br />
Field1 $dirty: {{form.form1.myRadio.$dirty}}<br />
Field2 $dirty: {{form.form2.myRadio.$dirty}}<br />
Value: {{myRadio}}
</form>
If you'd like a single check for the radio group, you can wrap all the radio buttons in their own ng-form and call it something like name="radioGroup".
http://jsfiddle.net/6VVBL/
<form name="form" novalidate>
<ng-form name="radioGroup">
<input type="radio"
name="myRadio1"
ng-model="myRadio"
ng-click=""
value="Rejected"
required>Rejected<br />
<input type="radio"
name="myRadio2"
ng-model="myRadio"
ng-click=""
value="Approved"
required>Approved<br />
</ng-form>
Form $dirty: {{form.$dirty}}<br />
Group $valid: {{form.radioGroup.$valid}}<br />
Group $dirty: {{form.radioGroup.$dirty}}<br />
Value: {{myRadio}}
</form>
This answer is related but perhaps not exactly applicable, but after finding and reading this item I felt it valuable to provide, and I don't have enough points to just comment on an answer (which I thought would have been a more appropriate way to respond).
My issue was that I wanted to show a required error (using ng-messages) but when you tabbed through / past the radio button group $touched didn't turn true unless you shift-tabbed back from the next UI element back to the last radio button of the group. (When my form renders the radio buttons are not set - I'm wanting the user to make a selection and not rely on the user accepting a default.)
Here's my code:
<div class="form-group" ng-class="{'has-error': pet.genderId.$invalid && pet.genderId.$touched}">
<label class="control-label">
What is your pet's gender?
<span ng-messages="pet.genderId.$error" ng-show="pet.genderId.$invalid && pet.genderId.$touched">
<span ng-message="required">(required)</span>
</span>
</label>
<div>
<label class="radio-inline"><input type="radio" ng-model="genderId" name="genderId" value="1" required ng-blur="pet.genderId.$setTouched();" />Male</label>
<label class="radio-inline"><input type="radio" ng-model="genderId" name="genderId" value="2" required ng-blur="pet.genderId.$setTouched();" />Female</label>
<label class="radio-inline"><input type="radio" ng-model="genderId" name="genderId" value="3" required ng-blur="pet.genderId.$setTouched();" />Not sure</label>
</div>
</div>
The 'magic' was adding the ng-blur attribute to set 'touched' myself even if only the first radio button was tabbed past.
You may be able to employ a similar tactic for $dirty by calling $setDirty() in the ng-changed attribute.

Resources