PrimeFaces how to reset background color - css

I have a reset button on my xhtml and basically when the field is empty it will prompt a message and the field background will turn to red.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<div id="cId" class="panel-body-width panel-input-body-width">
<div>
<div id="snDIV" class="row row-in-fieldset-div">
<div class="col-md-4">
<p:outputLabel id="myLabel" value="myNumber" />
</div>
<div class="col-semicolon col-md-1">
<p:outputLabel value=":" />
</div>
<div class="col-md-3 row-in-fieldset-cp">
<p:inputText id="myNumber"
value="#{userBean.myNumberInput}"
required="#{userBean.isRequired}"
requiredMessage="Input should not be empty" >
<p:ajax event="blur" update="myNumber myNumberMsg" />
</p:inputText>
</div>
</div>
<div class="col-md-3 row-in-fieldset-msg">
<p:message id="myNumberMsg" for="myNumber" />
</div>
</div>
</div>
</div>
<br />
<div class="panel-footer">
<p:commandButton id="reset" value="Reset"
actionListener="#{userBean.reset}" process="#this"
update="myNumber myNumberMsg" >
</p:commandButton>
</div>
</ui:composition>
Problem is, once i hit reset, the value does change to default and the error message disappears but the background color of the field is still red and does not change back to white. Anyone has an idea as to why?
I did try using the update=":form" but doesn't seem to work and my page won't load.

You should take a look at the resetInput component: http://www.primefaces.org/showcase/ui/misc/resetInput.xhtml

Related

Problems with the Prime faces's <p:inputNumber> element when used with the Sapphire Template

I am using JSF Mojarra 2.3.9.SP02 with PrimeFaces 7.0 running on Wildfly 17 with the PrimeFaces's own Sapphire template.
A few months ago I posted a question about a <p:inputText> element in my form, for which I have specified a placeholder, and whose initial value was empty. Here is my old question:
Problems with the attribute "placeholder" of an <p:inputText tag when the value of the inputText is empty
Now, I have two similar problems with a <p:inputNumber> element:
1.) When I use it without placeholder, like this:
<div class="ui-g-12 ui-md-6">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">
<i class="material-icons">account_circle</i>
</span>
<h:panelGroup styleClass="md-inputfield md-inputfield_marg_top">
<p:inputNumber id="minPreisId" autocomplete="off" value=""
decimalSeparator="," thousandSeparator="."/>
<p:message for="minPreisId" style="color: red">
<p:autoUpdate/>
</p:message>
<label>Min. Price</label>
</h:panelGroup>
</div>
</div>
I am able to enter numbers in the field, but the label "Min. Price" does not move upwards, so I am literally overwriting it ( the label and the value of the field I type in overlap with each other)
2.) When I use the <p:inputNumber> with a placeholder like this:
<div class="ui-g-12 ui-md-6">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">
<i class="material-icons">account_circle</i>
</span>
<h:panelGroup styleClass="md-inputfield md-inputfield_marg_top">
<p:inputNumber id="minPreisId" autocomplete="off" value=""
placeholder="€" symbol=" €" symbolPosition="s"
decimalSeparator="," thousandSeparator="."/>
<p:message for="minPreisId" style="color: red">
<p:autoUpdate/>
</p:message>
<label> Min. Price </label>
</h:panelGroup>
</div>
</div>
I see that the label, the placeholder and the value I type in the field altogether overlap and I am not able to distinguish the value I set
3.) When I replace <p:inputNumber> by <p:inputText> and put a placeholder like this:
<div class="ui-g-12 ui-md-6">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">
<i class="material-icons">account_circle</i>
</span>
<h:panelGroup styleClass="md-inputfield md-inputfield_marg_top">
<p:inputText id="minPreisId" autocomplete="off" value=""
placeholder="€" symbol=" €" symbolPosition="s"
decimalSeparator="," thousandSeparator="."/>
<p:message for="minPreisId" style="color: red">
<p:autoUpdate/>
</p:message>
<label>#{msg['immobilien.gesamt.mind.verkaufspreis']}"</label>
</h:panelGroup>
</div>
</div>
then my label moves upward when I type in a value in the field, but if the initial value is empty, then the placeholder and the label overlap, exactly as described in my question from several months ago.
Please help!
Below is my whole minimal working example:
<!DOCTYPE html>
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="shortcut icon" type="image/png" href="#{resource['img/Rauchfaenger.png']}"/>
</f:facet>
<title>Page Title </title>
<h:outputScript name="js/nanoscroller.js" library="sapphire-layout" />
<h:outputScript name="js/layout.js" library="sapphire-layout" />
<h:outputScript name="js/ripple.js" library="sapphire-layout" />
</h:head>
<h:body>
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces"/>
<div class="ui-g ui-fluid">
<div class="card card-w-title">
<h:form id="inseratForm">
<div class="card-title">Objekt anlegen trial</div>
<p:fieldset legend="Preis und Kosten" toggleable="true" toggleSpeed="500">
<div class="ui-g-12 ui-md-6">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">
<i class="material-icons">account_circle</i>
</span>
<h:panelGroup styleClass="md-inputfield md-inputfield_marg_top">
<p:inputNumber id="minPreisId" autocomplete="off" value=""
placeholder="€" symbol=" €" symbolPosition="s"
decimalSeparator="," thousandSeparator="."/>
<p:message for="minPreisId" style="color: red">
<p:autoUpdate/>
</p:message>
<label>#{msg['immobilien.gesamt.mind.verkaufspreis']}"</label>
</h:panelGroup>
</div>
</div>
<div class="ui-g-12 ui-md-6">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">
<i class="material-icons">account_circle</i>
</span>
<h:panelGroup styleClass="md-inputfield md-inputfield_marg_top">
<p:inputNumber id="betriebsKostenId" autocomplete="off" value=""
placeholder="€" symbol=" €" symbolPosition="s"
decimalSeparator="," thousandSeparator="."/>
<p:message for="betriebsKostenId" style="color: red">
<p:autoUpdate/>
</p:message>
<label>Betriebskosten (netto), EUR</label>
</h:panelGroup>
</div>
</div>
</p:fieldset>
</h:form>
</div>
</div>
<h:outputStylesheet name="css/nanoscroller.css" library="sapphire-layout" />
<h:outputStylesheet name="css/ripple.css" library="sapphire-layout" />
<h:outputStylesheet name="css/grid.css" library="sapphire-layout" />
<h:outputStylesheet name="css/layout-#{guestPreferences.layout}.css" library="sapphire-layout" />
</h:body>

Error resizing picklist and panel. Panel overlaps position of picklist

I have in one line a pickList and a panel but when I resize window then the panel overlaps pickList. Please see below code and screen(https://gofile.io/?c=iAqMJh). Only when panel arrives the arrows of the pickList then resizing happens without any error.
<div class="ui-g ui-fluid">
<div class="ui-g-12 ui-md-2">
<p:outputLabel
value="#{pageMsgs['citiesMSG.aaaa']}"
style="font-weight: bold" />
</div>
<div class="ui-md-4 ui-g-12">
<h:panelGroup>
<p:pickList id="pick1"
value="#{citiesBean.rowLevelCities}"
converter="#{pickListConverter}" var="cities"
responisve="true"
itemLabel="#{cities.name}" itemValue="#{cities}"
disabled="#{!citiesController.isEditMode(true)}">
<p:ajax event="transfer"
listener="#{citiesController.onTransferCityHeader}"
update="pick1 panelH" />
</p:pickList>
</h:panelGroup>
</div>
<div class="ui-md-6 ui-g-12">
<p:panel header="Header"
id="panelH">
<div class="ui-g ui-fluid">
<div class="ui-md-3 ui-g-12">
<p:outputLabel
value="#{pageMsgs['citiesMSG.cityHeader']}"
style="font-weight: bold" />
</div>
<div class="ui-md-1 ui-g-12" />
<div class="ui-md-3 ui-g-12">
<p:outputLabel
value="#{pageMsgs['citiesMSG.cityHeader']}"
style="font-weight: bold" />
</div>
</div>
</p:panel>
</div>
</div>
I'm using JSF 2.2

h:commandbutton does not work in navbar

I'm really not getting why my <h:commandbutton> wont work.
If I put the same commandbutton outside of the navbar, it works. the button becomes white if I hover over it. My code is the following:
<nav class=" navbar nav-bottom">
<img class="nav-item navbar-picture" src="#{resource['images/logo.gif']}" />
<img class="nav-item nav-logo-text" src="#{resource['images/retailsonar.svg']}" />
<div class="topnav-right">
<div style="float:left; margin-top:5px">
<h:outputText class="navbar-text" id="welkom" value="Welkom, #{userBean.getNaam()}"/>
</div>
<div style="float:right">
<h:form>
<h:commandButton class="btn-navbar" action="#{userBean.logout()}" value="logout" />
</h:form>
</div>
</div>
</nav>
<!-- navbar einde -->
<div class="vertical-center-full-page">
<center class="vertical-center">
<h:form>
<h:commandButton class="btn-navbar" action="#{userBean.logout()}" value="logout" />
</h:form>
the button in the navbar wont work
the button on the main screen does work, I can log out by clicking on it

How to align a checkbox and a text input tag into a jquery-mobile line

Using JqueryMobile, I wish to achieve the following layout:
Having nice decorations boxes to separate my input lines
Having one checkbox aligned vertically with an input text field, both on the same line
But after many attempts, the only layout I could come from with is the following:
The first attempt looks kind of right using jquerymobile grids, but my checkbox is not selectable anymore and remains checked forever. The second attempts uses the fieldset as proposed by the jquerymobile, but, I loose the checkbox and I tried using the css float property, without success.
Here is the full code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Multi-page template</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body style="font-size: 12px;">
<div data-role="page" id="one">
<div data-role="content">
<div class="ui-grid-a">
<div class="ui-block-a" style="width: 20%;" >
<div class="ui-bar ui-bar-e" style="height:24px; padding: .4em 4px;">
<div class="ui-checkbox">
<label data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="checkbox-off" class="ui-btn ui-btn-corner-all ui-btn-icon-left ui-checkbox-on">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-icon ui-icon-shadow ui-icon-checkbox-on"></span>
</span>
</label>
</div>
</div>
</div>
<div class="ui-block-b" style="width: 80%;" >
<div class="ui-bar ui-bar-e" style="height:24px">Block B</div>
</div>
</div>
<div style="height: 200px;">
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="checkbox" name="checkbox-mini-0" id="checkbox-mini-0" class="custom" />
<label for="checkbox-mini-0" >&nbsp</label>
<input type="text" name="texta" id="texta" class="custom" style="width:36px;" />
</fieldset>
<div style="height: 30px; border:1px solid lightgray;">
</div>
<div style="height: 30px; border:1px solid lightgray;">
</div>
</div>
</div>
</div>
</body>
</html>
Any help or comments to achieve my goal would be appreciated ?
Online editor: You can access the html file also on http://jsfiddle.net/alain_lavoie/XhsEh/
http://jsfiddle.net/XAsyy/110/
Updating from Nirmal Patel ans, I found textarea to work with checkboxes and if you do not want the textarea to grow:
data-role="none" ie. <textarea id="test" data-role="none"></textarea>
http://jsfiddle.net/XAsyy/144/
or, use:
css resize: none;
http://jsfiddle.net/nirmaljpatel/XAsyy/

Creating a custom editForm in Plone&Dexterity, how to save changes to an object?

We are working on a student project at our uni and we have to work with Plone and Dexterity content types.
We created a custom content type and are now trying to create a custom edit form for it. However, we don't seem be able to save anything we enter on the edit form to the Object itself.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="pacs.content">
<body>
<metal:main fill-slot="main">
<metal:main define-macro="main"
tal:define="currentSelection view/selected_org_unit">
<div tal:replace="structure provider:plone.abovecontenttitle" />
<h1 class="documentFirstHeading" tal:content="context/title" />
<div tal:replace="structure provider:plone.belowcontenttitle" />
<p class="documentDescription" tal:content="context/shortname" />
<div tal:replace="structure provider:plone.abovecontentbody" />
<div tal:content="structure context/projectnr" />
<div>
<fieldset style="border:1px #000 solid">
<legend>Bereichszuordnung</legend>
<select name="org_unit" size="1">
<option value="">Bitte auswählen</option>
<option
tal:repeat="code view/org_units"
tal:attributes="value code;
selected python:currentSelection == code and 'selected' or None"
tal:content="code"
/>
</select>
</fieldset>
</div>
<div tal:content="structure context/org_unit" />
<div tal:content="structure context/project_head" />
<div tal:content="structure context/confidential" />
<input id="form-buttons-save"
name="form.buttons.save" class="submit-widget button-field context" value="Save" type="submit" />
<div tal:replace="structure provider:plone.belowcontentbody" />
<div metal:use-macro="context/batch_macros/macros/navigation" />
</metal:main>
</metal:main>
Thanks in advance for any help you can offer and I will gladly upload any relevant code.
Are you registering the edit form?
class EditForm(dexterity.EditForm):
grok.context(IYourContentType)
Take a look at Custom add and edit forms for more information.

Resources