<table class="layout-table">
<tr>
<td><strong>3. Has the person completed all required training within the past three years?</strong><br/><br/></td>
</tr>
<tr>
<td><strong>a. Copy of It</strong>
<p:selectOneRadio id="radio3" value="#{question3a}">
<f:selectItem itemLabel="Yes" itemValue="0" />
<f:selectItem itemLabel="No" itemValue="1" />
<f:selectItem itemLabel="NA" itemValue="2" />
</p:selectOneRadio>
<br/>
<h:outputText id="counter3" />
</td>
</tr>
</table>
What I am trying to do is get a table to look like this
3. Has the person completed all required training within the past three years?
a. Copy of It Yes [] No[] NA[]
b. (another one) Yes [] No[] NA[]
I dont know how to tab the a and b and also if I make it where the buttons are to the right of the columns then it spaces it all the way to the very right hand side and I am not sure why.... Is this possible to do without CSS? If not then CSS would be fine too. Thanks for the help!
You might want to mark it up so it looks like this. I do agree that tables probably aren't the best solution for this problem.
<table class="layout-table">
<tr>
<td><strong>3. Has the person completed all required training within the past three years?</strong>
</tr>
<tr>
<td>
<table width="600" cellpadding="0" cellspacing="0" border="0" style="margin: 0 auto;">
<tr>
<td>
<p:selectOneRadio id="radio3" value="#{question3a}">
<f:selectItem itemLabel="Yes" itemValue="0" />
<f:selectItem itemLabel="No" itemValue="1" />
<f:selectItem itemLabel="NA" itemValue="2" />
</p:selectOneRadio>
</td>
</tr>
<tr>
<td>
<p:selectOneRadio id="radio3" value="#{question3a}">
<f:selectItem itemLabel="Yes" itemValue="0" />
<f:selectItem itemLabel="No" itemValue="1" />
<f:selectItem itemLabel="NA" itemValue="2" />
</p:selectOneRadio>
</td>
</tr>
</table>
</td>
</tr>
</table>
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 :-)
<h:form id="tableForm">
<table id="myTable">
<tr>
<th>HeaderOne</th>
<th>HeaderTwo</th>
<th>HeaderThree</th>
</tr>
<ui:repeat value="#{myBean.List}" var="row">
<tr class="myRows">
<td><input type="text" value="#{row.fieldOne} required="required" /></td>
<td><input type="text" value="#{row.fieldTwo} /></td>
<td><input type="text" value="#{row.fieldThree} /></td>
</tr>
</ui:repeat>
</table>
<p:commandButton id="myButton" value="Load" action="#{myBean.load}" process="#this" update="myTable" />
</h:form>
i want to load some stuff into my inputFields from my bean, but have one field that is required when i press save. So i have to set process to #this.
Afterwards i want my table to be updated. But i doesn't work.
What am i doing wrong?
try updating the form instead
<p:commandButton ... action="#{myBean.load}" process="#this" update="tableForm" />
since the table is not a jsf element but "pure" html, you can't use it's id in jsf elements
Schäbo answer is right (+1) but Primefaces also provides a p:fragment component so you may update only the region you want to:
<p:fragment id="myFragmentReloaded">
<table>
...
</table>
</p:fragment>
and then
<p:commandButton ... action="#{myBean.load}" process="#this" update="myFragmentReloaded" />
Hi guys I have a few radio buttons that I want vertical, but I can only seem to get the horizontal.
Currently my code is:
<p:panelGrid columns="1">
<p:selectOneRadio id="options" value="{formBean.number}">
<f:selectItem itemLabel="0 - 19" itemValue="1" />
<!-- Add in the help button by the side of each item once its lined up, use a grid ?
<p:button icon="ui-icon-help" title="Help">
</p:button> -->
<f:selectItem itemLabel="20 - 39" itemValue="2" />
<f:selectItem itemLabel="40 - 49" itemValue="4" />
<f:selectItem itemLabel="50 - 59" itemValue="5" />
<f:selectItem itemLabel="60 - 69" itemValue="6" />
<f:selectItem itemLabel="70 - 79" itemValue="7" />
<f:selectItem itemLabel="80 - 100" itemValue="8" />
</p:selectOneRadio>
</p:panelGrid>
How can I change it from horizontal to vertical, I have tried the grid way but still the same.
Thanks guys
EDIT
i have now achieved what i set out :
<p:panelGrid columns="1">
<p:selectOneRadio id="options" value="{formBean.number}" layout="grid" columns="1" required = "True"
requiredMessage="#{bundle.requiredGender}">
<f:selectItem itemLabel="0 - 19" itemValue="1" />
<f:selectItem itemLabel="20 - 39" itemValue="2" />
<f:selectItem itemLabel="40 - 49" itemValue="4" />
<f:selectItem itemLabel="50 - 59" itemValue="5" />
<f:selectItem itemLabel="60 - 69" itemValue="6" />
<f:selectItem itemLabel="70 - 79" itemValue="7" />
<f:selectItem itemLabel="80 - 100" itemValue="8" />
</p:selectOneRadio>
</p:panelGrid>
only issue is now the grid is the size of the page, any way this can be aligned to left and made only the size of the labes ?
Use the layout attribute on p:selectOneRadio with value pageDirection.
Here are possible values for layout:
lineDirection - For Horizontal Direction
pageDirection - For Vertical direction.
grid - For a grid pattern
pageDirection - For Vertical direction.
responsive - For dynamically using the space provided
custom - For custom Layout.
Example
I met a problem for two days. nowhere I advance
my problem is to make a dynamic content in a panel according to the selected element in the list p: selectOneMenu
<h:outputLabel value="Categorie :" />
<p:selectOneMenu value="#{composantbean.selectedCategoryId}" required="true" >
<f:selectItem itemLabel="Select categorie" itemValue="" />
<f:selectItems value="#{composantbean.listcat}" var="cat" itemValue="#{cat.nomCat}" itemLabel="#{cat.nomCat}" />
<p:ajax update="panl" event="change" listener="#{composantbean.catListener()}"/>
</p:selectOneMenu>
<p:panel id="panl" header ="Caracteristique selon la categorie" toggleable="true" rendered="true" >
<h:panelGrid id="panlecart" columns="2" cellpadding="5" rendered="true">
<c:forEach items="#{composantbean.categorie.proprietes}" var="var">
<h:outputText value="#{var.nomProp}"/>
<h:inputText value="" />
</c:forEach>
</h:panelGrid>
</p:panel>
content appears this is true but unfortunately it is not synchronized is displayed shift
but if I use another <p: selectOneMenu id = "panel" content is displayed and synchronized
Haw can I fixe my prblem .Please and thank you in advance
As Lucas said, it is a bad idea using c:foreach (and all kind of JSTL) in JSF, especially with ajax.
Here are references you should read, to know more about JSTL in JSF:
JSTL in JSF2 Facelets... makes sense?
https://rogerkeays.com/jsf-c-foreach-vs-ui-repeat
Using ui:repeat in h:panelGrid is not recommended also. You may read the discussion here.
So, IMHO, you should try another approach, such as using dataTable, as stated in above link.
Or, you could use html's table tag (<table>) as replacement of h:panelGrid, with html's tr and td tag inside ui:repeat. For example:
<h:outputLabel value="Categorie :" />
<p:selectOneMenu value="#{composantbean.selectedCategoryId}" required="true" >
<f:selectItem itemLabel="Select categorie" itemValue="" />
<f:selectItems value="#{composantbean.listcat}" var="cat" itemValue="#{cat.nomCat}" itemLabel="#{cat.nomCat}" />
<p:ajax update="panl" event="change" listener="#{composantbean.catListener()}"/>
</p:selectOneMenu>
<p:panel id="panl" header ="Caracteristique selon la categorie" toggleable="true" rendered="true" >
<table>
<ui:repeat value="#{composantbean.categorie.proprietes}" var="var">
<tr>
<td><h:outputText value="#{var.nomProp}" /></td>
<td><h:inputText value="" /></td>
</tr>
</ui:repeat>
</table>
</p:panel>
I have created web-application using JSF 2.0 where I have checkbox to select as h:selectManyCheckbox. Below is what I have as code
<h:selectManyCheckbox value="#{UserRegistration.pagesSelected}" id="myPages">
<f:selectItem itemValue="registerForPatentss" itemLabel="Register New Applicant"/>
<f:selectItem itemValue="success" itemLabel="Register New Project" />
<f:selectItem itemValue="getReportss" itemLabel="Patent Reports" />
<f:selectItem itemValue="searhPatentss" itemLabel="Search For Project" />
<f:selectItem itemValue="addUserss" itemLabel="Add User Account" />
<f:selectItem itemValue="logPatentSystemss" itemLabel="System Log" />
<f:selectItem itemValue="userlistss" itemLabel="Details Of Registered Users" />
</h:selectManyCheckbox>
Output I get is
[] Register New Applicant [] Register New Project [] Patent Reports [] Search For Project [] Add User Account [] System Log [] Details Of Registered Users
The problem is This is on ONE LINE.
What I want is as below.
[] Register New Applicant [] Register New Project [] Patent Reports [] Search For Project
[] Add User Account [] System Log [] Details Of Registered Users
i.e. 4 checkboxes on one line....
Any idea how to get this done?
Edit 1
HTML generated output is
<table id="myPages">
<tr>
<td>
<input name="myPages" id="myPages:0" value="registerForPatentss" type="checkbox" checked="checked" /><label for="myPages:0" class=""> Register New Applicant</label></td>
<td>
<input name="myPages" id="myPages:1" value="success" type="checkbox" checked="checked" /><label for="myPages:1" class=""> Register New Project</label></td>
<td>
<input name="myPages" id="myPages:2" value="getReportss" type="checkbox" checked="checked" /><label for="myPages:2" class=""> Patent Reports</label></td>
<td>
<input name="myPages" id="myPages:3" value="searhPatentss" type="checkbox" checked="checked" /><label for="myPages:3" class=""> Search For Project</label></td>
<td>
<input name="myPages" id="myPages:4" value="addUserss" type="checkbox" checked="checked" /><label for="myPages:4" class=""> Add User Account</label></td>
<td>
<input name="myPages" id="myPages:5" value="logPatentSystemss" type="checkbox" checked="checked" /><label for="myPages:5" class=""> System Log</label></td>
<td>
<input name="myPages" id="myPages:6" value="userlistss" type="checkbox" /><label for="myPages:6" class=""> Details Of Registered Users</label></td>
</tr>
</table>
Take a look at tomahawk's <t:selectManyCheckbox> with a straightforward usage description e.g. here.
You can do it with CSS:
<style type="text/css">
.cb table {
width: 100%;
}
.cb tr {
display: inline;
}
.cb td {
display: inline-block;
width: 24%;
}
</style>
<h:form>
<div class="cb">
<h:selectManyCheckbox value="#{UserRegistration.pagesSelected}" id="myPages">
<f:selectItem itemValue="registerForPatentss" itemLabel="Register New Applicant"/>
<f:selectItem itemValue="success" itemLabel="Register New Project"/>
<f:selectItem itemValue="getReportss" itemLabel="Patent Reports"/>
<f:selectItem itemValue="searhPatentss" itemLabel="Search For Project"/>
<f:selectItem itemValue="addUserss" itemLabel="Add User Account"/>
<f:selectItem itemValue="logPatentSystemss" itemLabel="System Log"/>
<f:selectItem itemValue="userlistss" itemLabel="Details Of Registered Users"/>
</h:selectManyCheckbox>
</div>
</h:form>
Used tomahawk's lib
xmlns:t="http://myfaces.apache.org/tomahawk"
<t:selectManyCheckbox value="#{UserRegistration.pagesSelected}" id="myPages" layout="pageDirection" layoutWidth="4">
<f:selectItem itemValue="registerForPatentss" itemLabel="Register New Applicant"/>
<f:selectItem itemValue="success" itemLabel="Register New Project" />
<f:selectItem itemValue="getReportss" itemLabel="Project Reports" />
<f:selectItem itemValue="searhPatentss" itemLabel="Search For Project" />
<f:selectItem itemValue="addUserss" itemLabel="Add User Account" />
<f:selectItem itemValue="logPatentSystemss" itemLabel="System Log" />
<f:selectItem itemValue="userlistss" itemLabel="Details Of Registered Users" />
</t:selectManyCheckbox>
Reference