<body>
<h3>Register for a prize by completing this form.</h3>
<s:form action="register">
<s:textfield name="personBean.firstName" label="First name" />
<s:textfield name="personBean.lastName" label="Last name" />
<s:textfield name="personBean.email" label ="Email"/>
<s:textfield name="personBean.age" label="Age" />
<input type="checkbox" checked="checked" />
<s:submit/>
</s:form>
<input type="checkbox" checked="checked" />
</body>
I have a jsp with above content. The checkbox within the form is not checked whereas the checkbox outside form is pre-checked. I am mixing up plain html checkbox and non-html elements within a Struts2 form.
Here you have malformed html by putting input tag like that in your form.
To resolve it,you can use s:checkbox
<s:checkbox name="checkMe" fieldValue="true" label="Check Me for testing" value="true"/>
Related
i hava a register page and i need if i select item radio for example item one password required get true and if i select item two required get false
<p:selectOneRadio id="connection" value="#{UserBean.connection}" >
<f:selectItem itemValue="One" />
<f:selectItem itemValue="two" />
</p:selectOneRadio>
and i want something with this logic
<c:if test="#{UserBean.connection =='One'}" >
<p:password id="pwd" value="#{UserBean.pwd}" required="false" />
</c:if>
<c:if>
<p:password id="pwd" value="#{UserBean.pwd}" required="true" />
</c:if>
kind regards and thanks in advance :-)
I make use of JSF , now I need to change the style of the radio buton by using plain HTML5 tag . How can I use the html tag to replace this
<h:selectOneRadio id="selectedAnswer" value="#{testBean.userAnswer}" layout="pageDirection">
<f:ajax event="change" execute="selectedAnswer" render="#none" />
<f:selectItems value="#{testBean.question.answers}" var="selectedAnswer" itemLabel="#{selectedAnswer.answer}" itemValue="#{selectedAnswer.id}" />
</h:selectOneRadio>
with this:
<ui:repeat var="selectedAnswer" value="#{testBean.question.answers}">
<label for="#{selectedAnswer.id}">
<input type="radio" id="#{selectedAnswer.id}" name="a-radio" value="#{selectedAnswer.id}" >
</input>
<span>#{selectedAnswer.answer}</span>
</label>
</ui:repeat>
How Can I set the value in the backing bean, in JSF you do this <h:selectOneRadio value="#{testBean.userAnswer}". in HTML what do you do?
How to implement checkbox within radio button in cq dialog? I have the following code in my cq dialog:
<<eyecatcher
jcr:primaryType="cq:Widget"
title="title"
name="title"
type="radio"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<yes jcr:primaryType="nt:unstructured"
text="yes"
value="yes" >
<items jcr:primaryType="cq:WidgetCollection">
<new jcr:primaryType="cq:Widget"
fieldLabel="new"
name="./new"
type="checkbox"
xtype="selection">
</new>
<offer jcr:primaryType="cq:Widget"
fieldLabel="Offer"
name="./offer"
type="checkbox"
xtype="selection">
</offer>
</items>
</yes>
<no jcr:primaryType="nt:unstructured"
text="no"
value="no"/>
</options>
</eyecatcher>
When I douple click on the dialog, I can see only the radio button. what did I do wrong?
I have the two text box(Using JSJ).
I have given txt box size as 50. It is working fine. Based on logic I have make one of the text to readonly disabled = true or disable = disabled. The read only text width is increasing its size.
When I inspect through f12,the size are showing 50 only,In inspect mode when i remove the
disable = disabled,it is reducing to actual size
I checked by the sample.
<h:inputText value="test" type="text" size="50">
</h:inputText>
<br/><br/>
<h:inputText value="tes1t" type="text" size="50" disabled="true">
</h:inputText>
I have pass the param to form as below :
Param
<ui:param name="validationMessageOnTheSameLine" value="true" />
<ui:param name="rowWidth" value="650px" />
<ui:param name="helpTextPaddingLeft" value="130px" />
<ui:param name="showAsterik" value="false" />
<ui:param name="showAsterikForUsername" value="false" />
<ui:param name="inputTextSize" value="50" />
<h:panelGrid columns="2" style="width: #{rowWidth}" id="emailValidated"
columnClasses="#{columnClass1}, #{columnClass2}">
<h:outputLabel value="#{uit.emailAddress}:" for="email">
<h:outputLabel styleClass="asterik" value="*"
rendered="#{showAsterik}" />
</h:outputLabel>
<h:panelGrid columns="2" styleClass="tableNoPadding">
<h:inputText value="#{userBean.emailAddress}" id="email"
styleClass="ux-margin-right-1t" size="#{inputTextSize}"
required="true" disabled="#{disableEmailInput}"
requiredMessage="#{uitkem.valueRequired}"
validatorMessage="#{uitkem.emailValidator}">
<f:validator validatorId="emailValidator" />
</h:inputText>
<rich:message for="email" />
</h:panelGrid>
</h:panelGrid>
Check that these <h:inputText> are enclosed in <h:form>.
Also, you don't need to add type="text" in <h:inputText>.
From my test environment (JSF 2.2), both these inputs have the same size when rendered.
I've got a login form that looks something like this, using RichFaces and Seam:
<h:form id="loginForm">
<h:outputLabel value="Username" />
<h:inputText value="#{identity.credentials.username}" />
<h:outputLabel value="Password" />
<h:inputText value="#{identity.credentials.password}" />
<h:commandLink action="#{identity.login()}" value="Login" />
</h:form>
I'd like to be able to allow the user to hit 'enter' and automatically submit the form to login. I've tried using Richfaces' <rich:hotKey /> feature, but I think I'm doing something wrong. The code I've put in looks like this:
<rich:hotKey key="return"
handler="#{rich:element('loginForm')}.submit()" />
However, when I hit enter inside the form, nothing happens. Any idea what I'm doing wrong here?
I think you need to use selector property. Something like,
<rich:hotKey key="return"
handler="#{rich:element('loginForm')}.submit()"
selector="#loginForm"/>
Also, instead of submitting the form, you should click submit button. Something like,
<rich:hotKey key="return"
handler="#{rich:element('loginButton')}.click()"
selector="#loginForm"/>
Try the following code. I hope you can get some idea..
<body>
<h:form id="loginForm">
<h:outputLabel value="Username : " />
<h:inputText id="userNameId" value="#{Login.username}" />
<h:outputLabel value="Password : " />
<h:inputText id="passwordId" value="#{Login.password}" />
<a4j:commandButton id="loginButton" action="#{Login.loginButton}" value="Login" focus="button"/>
<rich:hotKey key="return"
selector="#userNameId"
handler="#{rich:element('loginForm:loginButton')}.click();
event.stopPropagation();event.preventDefault();
return false;"/>
<rich:hotKey key="return"
selector="#passwordId"
handler="#{rich:element('loginForm:loginButton')}.click();
event.stopPropagation();event.preventDefault();
return false;"/>
</h:form>
</body>
For all those still struggling with this issue, I've finally gotten something that works. My code now looks like this:
<h:form id="loginForm">
<h:outputLabel value="Username" />
<h:inputText value="#{identity.credentials.username}" />
<h:outputLabel value="Password" />
<h:inputText value="#{identity.credentials.password}" />
<h:commandLink action="#{identity.login()}" value="Login" />
<rich:hotKey key="return"
handler="#{rich:element('loginForm')}.submit()"
selector="#loginForm"/>
</h:form>
You can also use a more specific selector so that an enter press only submits the form when the focus is on one of the form fields. Either way, this FINALLY solved my problem.