Page navigation in ICEFaces - eclipse

I recently started working on JSF in ICEFaces FrameWork(Server # Glassfish).
I have one question.
In my first JSF page i have radio buttons, If i to select and click on next page, I have to publish those selected values in my second page. If i click on back button , i have to show the selected values in my first page.
How can i achieve this? Please suggest
My First Page(suites.xhtml).
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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:ace="http://www.icefaces.org/icefaces/components">
<ui:composition template="/WEB-INF/templates/template.xhtml">
<ui:param name="title" value="Eclipse Template Test Page" />
<ui:param name="companyName" value="Autoexetc" />
<ui:define name="menuItems">
<ace:menuItem value="Dashboard" url="/dashboard.jsf" icon="ui-icon ui-icon-home"
styleClass="menuBarItem" />
<ace:menuItem value="Suites" url="/suites.jsf" styleClass="menuBarItem" />
<ace:menuItem value="Status" url="/status.jsf" styleClass="menuBarItem" />
<ace:menuItem value="Report" url="#" styleClass="menuBarItem" />
<ace:menuItem value="Terminal" url="#" styleClass="menuBarItem" />
</ui:define>
<ui:define name="tabItems">
Your in Suites Page <h:commandButton value="Back To DashBoard" action="dashboard" />
<br></br>
1. Hard-coded with "f:selectItem" :
<h:selectOneRadio value="#{user.favColor1}">
<f:selectItem itemValue="Red" itemLabel="Color1 - Red" />
<f:selectItem itemValue="Green" itemLabel="Color1 - Green" />
<f:selectItem itemValue="Blue" itemLabel="Color1 - Blue" />
</h:selectOneRadio>
<br />
2. Generated by Map :
<h:selectOneRadio value="#{user.favColor2}">
<f:selectItems value="#{user.favColor2Value}" />
</h:selectOneRadio>
<br />
3. Generated by Object array and iterate with var :
<h:selectOneRadio value="#{user.favColor3}">
<f:selectItems value="#{user.favColor3Value}" var="c"
itemLabel="#{c.colorLabel}" itemValue="#{c.colorValue}" />
</h:selectOneRadio>
<br />
<h:commandButton value="Submit" action="status" />
<h:commandButton value="Reset" type="reset" />
</ui:define>
</ui:composition>
</html>
And My Result Page (status.Xhtml), which gives my selected values.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<ui:composition template="/WEB-INF/templates/template.xhtml">
<ui:param name="title" value="Eclipse Template Test Page" />
<ui:param name="companyName" value="Autoexetc" />
<ui:define name="menuItems">
<ace:menuItem value="Dashboard" url="/dashboard.jsf" icon="ui-icon ui-icon-home"
styleClass="menuBarItem" />
<ace:menuItem value="Suites" url="/suites.jsf" styleClass="menuBarItem" />
<ace:menuItem value="Status" url="/status.jsf" styleClass="menuBarItem" />
<ace:menuItem value="Report" url="#" styleClass="menuBarItem" />
<ace:menuItem value="Terminal" url="#" styleClass="menuBarItem" />
</ui:define>
<ui:define name="tabItems">
Your in status Page <h:commandButton value="Back To suites" action="suites" />
<br/>
<ol>
<li>user.favColor1 : #{user.favColor1}</li>
<li>user.favColor2 : #{user.favColor2}</li>
<li>user.favColor3 : #{user.favColor3}</li>
</ol>
</ui:define>
When i click on back button from my result page, first page will display with selected values, if i re-select any values and submit it, cant able to navigate to my result page.

Related

setPropertyActionListener within commandlink not working

The datatable displays entries that I intend to be able to edit. In order to do so, I use a commandlink to open a dialog box. setPropertyActionListener sets the CostingType object that should be able to be modified from within the dialog box. However, the dialog box isn't able to get the object's variables or save them. Instead, it shows an empty object and clicking on the edit button(after keying in fields) shows the requiredMessage warnings instead. checkEdit() (which exists solely for debug purposes) isn't being called either.
HTML:
<h:form id="costingTypeForm" >
<p:tabView id="tabView">
<p:tab id="tab1" title="Costing Type">
<h:form id="costingTypeForm" >
<p:tabView id="tabView">
<p:tab id="tab1" title="Costing Type">
<p:dataTable
id="costingTypeTable"
value="#{costingTypeBean.costingTypeList}"
var="costingType"
rows="#{psmsProp['psms.dataTable.rows']}"
paginator="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {CurrentPageReport}"
rowsPerPageTemplate="#{psmsProp['psms.dataTable.rowsPerPage']}"
currentPageReportTemplate="Displaying {startRecord}-{endRecord} out of {totalRecords}"
style="width:80%; text-align:center;"
sortBy="#{costingType.name}"
sortMode="single" >
<f:facet name="header">
Costing Type
<p:commandButton
value="Add"
oncomplete="PF('addCostingTypeDialog').show()"
update="costingTypeForm:tabView:addCostingTypeForm"
icon="ui-icon-plus"
style="float:right;" />
<div style="clear:both" />
</f:facet>
<p:column sortBy="#{costingType.name}"
filterBy="#{costingType.name}"
filterMatchMode="contains"
filterFunction="#{filterUtil.containsFilter}"
filterStyle="width:80%;"
headerText="Name">
<p:outputLabel id = "name" value="#{costingType.name}" />
</p:column>
<p:column headerText="Description">
<p:outputLabel id = "description" value="#{costingType.nameDesc}" />
</p:column>
<p:column headerText="Budgeted">
<p:outputLabel value="Yes" rendered="#{costingType.budget}" />
<p:outputLabel value="No" rendered="#{not costingType.budget}" />
</p:column>
<p:column headerText="Deleted">
<p:outputLabel value="Yes" rendered="#{costingType.del}" />
<p:outputLabel value="No" rendered="#{not costingType.del}" />
</p:column>
<p:column>
<p:commandLink
oncomplete="PF('editCostingTypeDialog').show()"
update=":costingTypeForm:tabView:editCostingTypeForm"
value="Edit" action="#{costingTypeBean.checkEdit}">
<f:setPropertyActionListener target="#{costingTypeBean.editCostingType}" value="#{costingType}"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog
header="Edit Costing Type"
widgetVar="editCostingTypeDialog"
modal="true"
showEffect="slide"
hideEffect="fade"
resizable="false"
closable="false">
<p:outputPanel id="editCostingTypeForm">
<p:panelGrid columns="2" cellpadding="5" rendered="#{not empty costingTypeBean.editCostingType}">
<h:panelGroup>
<p:outputLabel value="Name:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:inputText value="#{costingTypeBean.editCostingType.name}" required="true" requiredMessage="Name is required" />
<h:panelGroup>
<p:outputLabel value="Description:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:inputText value="#{costingTypeBean.editCostingType.nameDesc}" required="true" requiredMessage="Description is required" />
<p:outputLabel value="Budgeted:" />
<p:selectOneMenu value="#{costingTypeBean.editCostingType.budget}">
<f:selectItem itemValue="true" itemLabel="Yes" />
<f:selectItem itemValue="false" itemLabel="No" />
</p:selectOneMenu>
<h:outputLabel value="Deleted:" />
<p:selectOneMenu value="#{costingTypeBean.editCostingType.del}">
<f:selectItem itemValue="true" itemLabel="Yes" />
<f:selectItem itemValue="false" itemLabel="No" />
</p:selectOneMenu>
</p:panelGrid>
<p:commandButton
value="Cancel"
actionListener="#{costingTypeBean.cancelChange}"
oncomplete="PF('editCostingTypeDialog').hide();"
icon="ui-icon-close"
style="float:right;margin-top:10px;margin-bottom:10px;" />
<p:commandButton
value="Edit"
actionListener="#{costingTypeBean.updateCostingType}"
oncomplete="if(args.update) PF('editCostingTypeDialog').hide();"
update=":costingTypeForm:messages #(.ui-datatable)"
icon="ui-icon-disk"
style="float:right;margin-top:10px;margin-right:10px;margin-bottom:10px;" />
</p:outputPanel>
</p:dialog>
<p:dialog
header="Add New CostingType"
widgetVar="addCostingTypeDialog"
modal="true"
showEffect="slide"
hideEffect="fade"
resizable="false"
closable="false">
<p:outputPanel id="addCostingTypeForm">
<p:panelGrid columns="2" cellpadding="5">
<h:panelGroup>
<p:outputLabel value="Name" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:inputText value="#{costingTypeBean.name}" required="true" requiredMessage="Enter name" />
<h:panelGroup>
<p:outputLabel value="Description:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:inputText value="#{costingTypeBean.nameDesc}" required="true" requiredMessage="Enter Engine Type" />
<h:panelGroup>
<h:outputLabel value="Budgeted:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:selectOneRadio value="#{costingTypeBean.budgeted}">
<f:selectItem itemValue="true" itemLabel="Yes" />
<f:selectItem itemValue="false" itemLabel="No" />
</p:selectOneRadio>
<h:panelGroup>
<h:outputLabel value="Deleted:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:selectOneRadio value="#{costingTypeBean.deleted}">
<f:selectItem itemValue="true" itemLabel="Yes" />
<f:selectItem itemValue="false" itemLabel="No" />
</p:selectOneRadio>
</p:panelGrid>
<p:commandButton
value="Cancel"
actionListener="#{costingTypeBean.cancelChange}"
oncomplete="PF('addCostingTypeDialog').hide();"
icon="ui-icon-close"
style="float:right;margin-top:10px;margin-bottom:10px;" />
<p:commandButton
value="Save"
actionListener="#{costingTypeBean.addCostingType}"
oncomplete="if(args.add) PF('addCostingTypeDialog').hide(); else PF('addCostingTypeDialog').show();"
update="#form #(.ui-datatable)"
icon="ui-icon-disk"
style="float:right;margin-top:10px;margin-right:10px;margin-bottom:10px;" />
</p:outputPanel>
</p:dialog>
</p:tab>
</p:tabView>
</h:form>
Backing bean:
#Component
#Scope("view")
public class CostingTypeBean{
private static final Logger LOGGER = LoggerFactory.getLogger(CostingTypeBean.class);
private long costingTypeId;
private boolean budgeted, deleted;
private String name, nameDesc;
private CostingType costingType;
private CostingType editCostingType;
private List<CostingType> costingTypeList;
#Autowired
private CostingTypeService costingTypeService;
/*
getters and setters
*/
// dialog edit
public void updateCostingType(ActionEvent event) {
RequestContext context = RequestContext.getCurrentInstance();
if(editCostingType!=null) {
costingTypeService.saveOrUpdate(editCostingType);
context.addCallbackParam("update", true);
}
else
context.addCallbackParam("update", false);
}
//debug method
public void checkEdit() {
LOGGER.debug("Edit listener");
ViewUtil.showInfo("Edit dialog triggered");
System.out.println("Edit listener");
}
What should I do to get editCostingTypeDialog to reflect the fields of of the CostingType object and be able to read the values keyed in the input text areas?
Your code works just fine. All I had to do was to modify some of the update= attributes (as I was getting exceptions about destination components not being found). After populating with some random data and using your above code I get the following;
I tested with both PrimeFaces 6.1 and 6.2 on Mojarra 2.3.3.99. The backing bean callback for the edit button in the dialog is also being called properly.
So the next thing to check - which JSF implementation are you using? Is it Mojarra or MyFaces ? which version ? Maybe you are hitting upon some bug in your specific implementation. There is absolutely nothing wrong with your code.
While I'm at it, I might as well post the complete code (including my modifications);
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Costing type Test</title>
</h:head>
<h:body>
<h:form id="costingTypeForm" >
<p:tabView id="tabView">
<p:tab id="tab1" title="Costing Type">
<p:dataTable
id="costingTypeTable"
value="#{costingTypeBean.costingTypeList}"
var="costingType"
paginator="true"
style="width:80%; text-align:center;"
sortMode="single" >
<f:facet name="header">
Costing Type
<p:commandButton value="Add" oncomplete="PF('addCostingTypeDialog').show()" update="#form" icon="ui-icon-plus" style="float:right;" />
<div style="clear:both" />
</f:facet>
<p:column sortBy="#{costingType.name}"
filterBy="#{costingType.name}"
filterMatchMode="contains"
filterFunction="#{filterUtil.containsFilter}"
filterStyle="width:80%;"
headerText="Name">
<p:outputLabel id = "name" value="#{costingType.name}" />
</p:column>
<p:column headerText="Description">
<p:outputLabel id = "description" value="#{costingType.nameDesc}" />
</p:column>
<p:column headerText="Budgeted">
<p:outputLabel value="Yes" rendered="#{costingType.budget}" />
<p:outputLabel value="No" rendered="#{not costingType.budget}" />
</p:column>
<p:column headerText="Deleted">
<p:outputLabel value="Yes" rendered="#{costingType.del}" />
<p:outputLabel value="No" rendered="#{not costingType.del}" />
</p:column>
<p:column>
<p:commandLink
oncomplete="PF('editCostingTypeDialog').show()"
update=":costingTypeForm:tabView:editCostingTypeForm"
value="Edit" action="#{costingTypeBean.checkEdit}">
<f:setPropertyActionListener target="#{costingTypeBean.editCostingType}" value="#{costingType}"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog
header="Edit Costing Type"
widgetVar="editCostingTypeDialog"
modal="true"
showEffect="slide"
hideEffect="fade"
resizable="false"
closable="false">
<p:outputPanel id="editCostingTypeForm">
<p:panelGrid columns="2" rendered="#{not empty costingTypeBean.editCostingType}">
<h:panelGroup>
<p:outputLabel value="Name:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:inputText value="#{costingTypeBean.editCostingType.name}" required="true" requiredMessage="Name is required" />
<h:panelGroup>
<p:outputLabel value="Description:" />
<p:outputLabel value="*" style="color:red;" />
</h:panelGroup>
<p:inputText value="#{costingTypeBean.editCostingType.nameDesc}" required="true" requiredMessage="Description is required" />
<p:outputLabel value="Budgeted:" />
<p:selectOneMenu value="#{costingTypeBean.editCostingType.budget}">
<f:selectItem itemValue="true" itemLabel="Yes" />
<f:selectItem itemValue="false" itemLabel="No" />
</p:selectOneMenu>
<h:outputLabel value="Deleted:" />
<p:selectOneMenu value="#{costingTypeBean.editCostingType.del}">
<f:selectItem itemValue="true" itemLabel="Yes" />
<f:selectItem itemValue="false" itemLabel="No" />
</p:selectOneMenu>
</p:panelGrid>
<p:commandButton
value="Cancel"
actionListener="#{costingTypeBean.cancelChange}"
oncomplete="PF('editCostingTypeDialog').hide();"
icon="ui-icon-close"
style="float:right;margin-top:10px;margin-bottom:10px;" />
<p:commandButton
value="Edit"
actionListener="#{costingTypeBean.updateCostingType}"
oncomplete="if(args.update) PF('editCostingTypeDialog').hide();"
update="#form"
icon="ui-icon-disk"
style="float:right;margin-top:10px;margin-right:10px;margin-bottom:10px;" />
</p:outputPanel>
</p:dialog>
</p:tab>
</p:tabView>
</h:form>
</h:body>
</html>
And here is the backing bean (example uses Lombok and Apache Commons);
#Data
#Named
#ViewScoped
public class CostingTypeBean implements Serializable {
private CostingType costingType;
private CostingType editCostingType;
private List<CostingType> costingTypeList;
#PostConstruct
private void init() {
costingTypeList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
final String name = RandomStringUtils.randomAlphanumeric(10);
final String nameDesc = RandomStringUtils.randomAlphanumeric(10);
final boolean budget = RandomUtils.nextBoolean();
final boolean del = RandomUtils.nextBoolean();
costingTypeList.add(new CostingType(name, nameDesc, budget, del));
}
}
public void updateCostingType(ActionEvent event) {
System.out.println("update!");
}
public void checkEdit() {
System.out.println("Edit listener");
}
public void cancelChange() {
System.out.println("Cancel");
}
#Data
#AllArgsConstructor
public class CostingType {
private String name;
private String nameDesc;
private boolean budget;
private boolean del;
}
}
Hopefully this can be of some help.
It's a bug in PrimeFaces (I think).
I searched with many tests in a minimal test application. It's not possible to use following constellation:
<p:dataTable value="#{bean.list}" var="myVar".....
<p:ajax event="rowSelect" partialSubmit="true" process="#this" listener="#{bean.doWork(myVar)}"/>
bean.doWork() will always be called with a null pointer.
Glassfish 4.1.1
PrimeFaces 6.2
I think your problem is the same.

The type of element "p: dataTable" must be followed by one of these attribute specifications, ">" or "/>"."

well, simply...the trouble is while i try to run my jsf proyect using primefaces, it does not..and splash on the browser an error screen what says
"Estado HTTP 500 - Error Parsing /Lista.xhtml: Error Traced[line: 37] El tipo de elemento "p:dataTable" debe ir seguido de una de estas especificaciones de atributo: ">" o "/>"."
"HTTP Status 500 - /Lista.xhtml Parsing Error: Error Traced [line 37] The type of element "p: dataTable" must be followed by one of these attribute specifications, ">" or "/>"."
well i tried anything even clean and validating and looking minutely each codeline, so..please help ill be glad of your help...
here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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">
<ui:composition template="Template.xhtml">
<ui:define name="content">
<h:head>
<title>Welcome</title>
</h:head>
<h:body>
<h:form>
<p:panelGrid style="margin: 0 auto" columns="2">
<p:outputLabel value="Nombres" />
<p:inputText p:placeholder="Ej; Edward" value="#{personaBean.persona.nombre}"></p:inputText>
<p:outputLabel value="Apellidos" />
<p:inputText p:placeholder="Ej; Snowden"
value="#{personaBean.persona.apellido}" />
<p:outputLabel value="Sexo" style="center" />
<p:selectOneMenu value="#{personaBean.persona.sexo}">
<f:selectItem itemValue="Masculino." itemLabel="Masculino." />
<f:selectItem itemValue="Femenino." itemLabel="Femenino." />
</p:selectOneMenu>
<p:commandButton value="Enviar" actionListener="#{personaBean.agregamePersona}" update="dt" ></p:commandButton>
</p:panelGrid>
<!-- <p:growl id="msj" showDetail="true"/> -->
<p:dataTable id="dt"
value="#{personaBean.lstPersonas}"
border="1"var="p" rows="4"
paginator="true"
paginatorTemplate="{CurrentPageReport}
{FirstPageLink}
{PreviousPageLink}
{PageLinks}
{NextPageLink}
{LastPageLink}
{Exporters}"
tableStyle="widh:auto"
rowsPerPageTemplate="1,2,3,5" >
<p:column filterBy="#{p.nombre}" filterMatchMode="contains"headerText="Nombre" style="width:100px" >
<h:outputText value="#{p.nombre}" />
</p:column>
<p:column headerText="Apellido" filterBy="#{p.apellido}" filterMatchMode="contains"style="width:100px">
<h:outputText value="#{p.apellido}" />
</p:column>
<p:column headerText="Sexo" filterBy="#{p.sexo}" filterMatchMode="contains"style="width:100px" sortBy="#{p.sexo}">
<h:outputText value="#{p.sexo}" />
</p:column>
<p:column style="width:40px">
<h:panelGrid columns="3" styleClass="Actions" cellpadding="2">
<p:commandButton id="eraseButton" value="Eliminar"actionListener="#{personaBean.eliminamePersona(p)}" update="dt" />
<p:commandButton id="selectButton" update=":form:display" oncomplete="interactiveDialog.show()" icon="ui-icon-search" title="View">
<f:setPropertyActionListener value="#{p}" target="#{personaBean.persona}" />
</p:commandButton>
</h:panelGrid>
</p:column>
</p:dataTable>
<p:dialog header="Detalle del cliente" widgetVar="interactiveDialog" resizable="false" id="dialogointeractivo"
showEffect="fade" hideEffect="explode" modal="true">
<h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">
<f:facet name="header">
<h:outputText value="Datos de la fila seleccionada"/>
</f:facet>
<h:outputText value="Nombre"/>
<h:outputText value="#{personaBean.persona.nombre}" style="font-weight:bold"/>
<h:outputText value="Apellido"/>
<h:outputText value="#{personaBean.persona.apellido}" style="font-weight:bold"/>
<h:outputText value="Sexo"/>
<h:outputText value="#{personaBean.persona.sexo}" style="font-weight:bold"/>
</h:panelGrid>
</p:dialog>
</h:form>
</h:body>
</ui:define>
</ui:composition>
</html>

iTextSharp SetField for fields with same name on different pages

I used acroFields.GetTranslatedFieldName() to get the next fieldnames from the pdf:
topmostSubform[0].Page1[0].CheckBox2A[0]
topmostSubform[0].Page1[0].CheckBox2A[1]
topmostSubform[0].Page2[0].CheckBox2A[0]
topmostSubform[0].Page2[0].CheckBox2A[1]
topmostSubform[0].Page3[0].CheckBox2A[0]
topmostSubform[0].Page3[0].CheckBox2A[1]
I use the next line of code to fill CheckBox2A[0] on the second page.
fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1")
Instead of CheckBox2A[0] on the second page, CheckBox2A[0] on the first page gets checked.
iTextSharp (and also iText for Java, tested here) does not correctly associate the reference derived from the XFA template structure
topmostSubform[0].Page2[0].CheckBox2A[0]
with the matching entry in the one XFA dataset:
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" >
<xfa:data >
<topmostSubform >
<!-- vvv the incorrect match by iText -->
<CheckBox2A >0</CheckBox2A >
<!-- ^^^ the incorrect match by iText -->
<CheckBox2A >0</CheckBox2A >
<CheckBox2B >0</CheckBox2B >
<CheckBox2B >0</CheckBox2B >
<Voorletters />
<Achternaam />
<CheckBox2C >0</CheckBox2C >
<CheckBox2C >0</CheckBox2C >
<DatumDag />
<DatumMaand />
<DatumJaar />
<TextField1 />
<HuisNrTekst5 />
<HuisNrNummer5 />
<Straat />
<PostcodeNr1c />
<PostcodeAlpha1c />
<Plaats />
<HuisNrTekst5 />
<HuisNrNummer5 />
<TextField1 />
<PostcodeNr1c />
<PostcodeAlpha1c />
<Plaats />
<TextField1 />
<CheckBox2D >0</CheckBox2D >
<CheckBox2D >0</CheckBox2D >
<IBANREKC_1 />
<IBANREKB_1 />
<IBANREKA_1 />
<IBAN_1 />
<BurgerserviceNr />
<Voorletters />
<Achternaam />
<CheckBox2E >0</CheckBox2E >
<CheckBox2E >0</CheckBox2E >
<HuisNrTekst5 />
<HuisNrNummer5 />
<Straat />
<PostcodeNr1c />
<PostcodeAlpha1c />
<Plaats />
<DatumDag />
<DatumMaand />
<DatumJaar />
<IBANREKC_2 />
<IBANREKB_2 />
<IBANREKA_2 />
<IBAN_2 />
<Telefoon />
<!-- vvv the correct match -->
<CheckBox2A >0</CheckBox2A >
<!-- ^^^ the correct match -->
<CheckBox2A >0</CheckBox2A >
<CheckBox2B >0</CheckBox2B >
<CheckBox2B >0</CheckBox2B >
<IBANREKC_1 />
<IBANREKB_1 />
<IBANREKA_1 />
<IBAN_1 />
<CheckBox2C >0</CheckBox2C >
<CheckBox2C >0</CheckBox2C >
<TextField1 />
<TextField1 />
<CheckBox2D >0</CheckBox2D >
<CheckBox2D >0</CheckBox2D >
<Telefoon />
<CheckBox2E >0</CheckBox2E >
<CheckBox2E >0</CheckBox2E >
<CheckBox2F >0</CheckBox2F >
<CheckBox2F >0</CheckBox2F >
<TextField1 />
<TextField1 />
<CheckBox2G >0</CheckBox2G >
<CheckBox2G >0</CheckBox2G >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<IBAN_1E_01 />
<IBAN_1D_01 />
<IBAN_1C_01 />
<IBAN_1A_01 />
<IBAN_1B_01 />
<IBANREKC_1 />
<IBANREKB_1 />
<IBANREKA_1 />
<IBAN_1 />
<IBAN_1E_02 />
<IBAN_1D_02 />
<IBAN_1C_02 />
<IBAN_1B_02 />
<IBAN_1A_02 />
<CheckBox3D >0</CheckBox3D >
<CheckBox3D >0</CheckBox3D >
<CheckBox3D >0</CheckBox3D >
<CheckBox3A >0</CheckBox3A >
<CheckBox3A >0</CheckBox3A >
<CheckBox3A >0</CheckBox3A >
<CheckBox2A >0</CheckBox2A >
<CheckBox2A >0</CheckBox2A >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<DatumDag />
<DatumMaand />
<DatumJaar />
<TextField1 />
<DatumDag />
<DatumMaand />
<DatumJaar />
<TextField1 />
<Telefoon />
</topmostSubform >
</xfa:data >
</xfa:datasets >
Thus, the wrong dataset element is changed. I'm afraid this has to be looked into by iText development, I have no fix at hand.
You might be in luck, though: The form in your document actually is a hybrid with both an AcroForm and an XFA representation. During your fields.SetField call iText attempts to set the value in both representations, and indeed, in the AcroForm representation it sets the correct one.
Thus, if the result PDF is not required to carry that XFA structure anymore, you can simply drop the XFA structure:
using (var pdfReader = new PdfReader(file))
using (FileStream output = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, output))
{
AcroFields fields = pdfStamper.AcroFields;
fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1");
fields.RemoveXfa();
}
Doing that you get the tick on page 2:

Prevent tab-siwtch on p:tabView when form validation fails

I'm using a tabView-Element of primefaces. The first tab points to the "Home" element the second one to a registration form. The registration form is validated. The problem is, when the form is validated the user is redirect to the home tab. When the user navigates back, he can see the validation errors.
This seems to be a more or less common problem, but I did not find a proper solution. I tried out Oleg Varaksin suggestion to prevent a user switching tabs when a form validation failed, but my problem starts earlier.
I tried to fiddle aorund with the onTabChange event but with no success. Is there a mistake in my code or how can I approach may probelm? I would welcome a push in the right direction.
<p:tabView id="mainTabView">
<p:tab title="Startseite" id="startPage">
<p:layout style="min-width:400px;min-height:400px;border:none !important"
id="layout_login">
<p:layoutUnit position="west" size="305">
<p:panel>
<h:form id="loginForm">
<p:panelGrid columns="2" styleClass="gridWithNoBorders reducedFontSize">
<p:outputLabel value="Benutzername:" />
<p:inputText size="14" value="#{data.username}" />
<p:outputLabel value="Passwort:" />
<p:inputText size="14" value="#{data.loginPassword}" />
</p:panelGrid>
<p:separator />
<h:commandButton styleClass="reducedFontSize" value="Anmelden" />
</h:form>
</p:panel>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:panel>
Lorem ipsum dolor sit amet(...)
</p:panel>
</p:layoutUnit>
</p:layout>
</p:tab>
<p:tab id="registrationPage" title="#{ivy.cms.co('/Translations/Registration/tabTitleRegistration')}" >
<h:form id="registrationForm">
<p:panel header="#{ivy.cms.co('/Translations/Registration/panelHeaderRegistration')}">
<p:panelGrid columns="3">
<p:outputLabel value="#{ivy.cms.co('/Translations/Registration/labelEmail')}" />
<p:inputText value="#{data.email}" id="email1" required="true" requiredMessage="#{ivy.cms.co('/Translations/Registration/enterEmailAddress')}">
<f:validator validatorId="EmailValidator" />
<f:validator validatorId="EmailCompareValidator" />
</p:inputText>
<p:message for="email1" />
<p:outputLabel value="#{ivy.cms.co('/Translations/Registration/labelRepeatEmail')}" />
<p:inputText value="#{data.emailConfirm}" id="email2" required="true" requiredMessage="#{ivy.cms.co('/Translations/Registration/repeatMailAddress')}">
<f:validator validatorId="EmailValidator" />
</p:inputText>
<p:message for="email2"/>
<p:outputLabel value="#{ivy.cms.co('/Translations/Registration/labelPrename')}" />
<p:inputText value="#{data.prename}" id="prename" required="true" requiredMessage="#{ivy.cms.co('/Translations/Registration/enterPrename')}"/>
<p:message for="prename"/>
<p:outputLabel value="#{ivy.cms.co('/Translations/Registration/labelSurname')}" />
<p:inputText value="#{data.surname}" id="surname" required="true" requiredMessage="#{ivy.cms.co('/Translations/Registration/enterSurname')}"/>
<p:message for="surname"/>
<p:outputLabel value="#{ivy.cms.co('/Translations/Registration/labelPassword')}" />
<p:password id="pwd1" value="#{data.registrationPassword}" match="pwd2"
required="true" feedback="true" requiredMessage="#{ivy.cms.co('/Translations/Registration/enterPassword')}"
weakLabel="#{ivy.cms.co('/Translations/Registration/passwordWeak')}"
goodLabel="#{ivy.cms.co('/Translations/Registration/passwordMedium')}"
strongLabel="#{ivy.cms.co('/Translations/Registration/passwordStrong')}" />
<p:message for="pwd1"/>
<p:outputLabel value="#{ivy.cms.co('/Translations/Registration/labelRepeatPassword')}" />
<p:password id="pwd2" value="#{data.confirmPassword}" required="true" requiredMessage="#{ivy.cms.co('/Translations/Registration/repeatPassword')}"/>
<p:message for="pwd2"/>
<h:commandButton value="#{ivy.cms.co('/Translations/Registration/finishRegistration')}" actionListener="#{logic.startRegistration}" >
<p:ajax event="click" listener="#{logic.startRegistration}"/>
</h:commandButton>
</p:panelGrid>
</p:panel>
</h:form>
</p:tab>
</p:tabView>
I had to combine the binding and ajax to achieve my goal. It seems that the activeIndex is resetted after the form validation (?) therefore it is not honored after submitting the form. I've used the approach that was suggested by Steves to use the binding property. So here is the working code:
xhtml:
<p:layoutUnit position="center">
<p:tabView id="mainTabView" binding="#{tabIndexHelper.messagesTab}">
<p:ajax event="tabChange" listener="#{tabIndexHelper.onTabChange}" />
<p:tab title="Startseite" id="startPage">
<ui:include src="HomePage.xhtml" />
</p:tab>
<p:tab id="registrationPage" title="#{ivy.cms.co('/Translations/Registration/tabTitleRegistration')}" >
<ui:include src="RegisterPage.xhtml" />
</p:tab>
</p:tabView>
</p:layoutUnit>
And the backing bean:
private TabView messagesTab = new TabView();
public TabView getMessagesTab () {
return messagesTab;
}
public void setMessagesTab(TabView messagesTab ) {
this.messagesTab = messagesTab;
}
public void onTabChange(TabChangeEvent event) {
TabView tabView = (TabView) event.getComponent();
int activeIndex = tabView.getChildren().indexOf(event.getTab());
this.messagesTab.setActiveIndex(activeIndex);
}
Thanks for support. :)
You need to fix the current tab selected if you don't the update or validation should reset the tabview with default tab selected(the first one).
So you could use activeIndex attribut from tabView :
<p:tabView activeIndex="#{bean.activeIndex}"/>
From Primeface User Guide:
activeIndex is an Integer with default value 0. Index of the active tab.
And create an event for set this var like that :
<p:ajax event="tabChange" listener="#{bean.onTabChange}"/>

primefaces not working with eclipse indigo

i'm doing some stuff with primefaces om eclipse indigo, i made a dynamic web project and selects the project facets and included the primefaces jar primefaces-3.5.jar i made a new xhtml page and write some code to make a new menubar, these is the final page that i run :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form>
<p:growl id="messages"/>
<h3>Default Menubar</h3>
<p:menubar>
<p:submenu label="File" icon="ui-icon-document">
<p:submenu label="New" icon="ui-icon-contact">
<p:menuitem value="Project" url="#" />
<p:menuitem value="Other" url="#" />
</p:submenu>
<p:menuitem value="Open" url="#" />
<p:separator />
<p:menuitem value="Quit" url="#" />
</p:submenu>
<p:submenu label="Edit" icon="ui-icon-pencil">
<p:menuitem value="Undo" url="#" icon="ui-icon-arrowreturnthick-1-e" />
<p:menuitem value="Redo" url="#" icon="ui-icon-arrowreturnthick-1-e" />
</p:submenu>
<p:submenu label="Help" icon="ui-icon-help">
<p:menuitem value="Contents" url="#" />
<p:submenu label="Search" icon="ui-icon-search">
<p:submenu label="Text">
<p:menuitem value="Workspace" url="#" />
</p:submenu>
<p:menuitem value="File" url="#" />
</p:submenu>
</p:submenu>
<p:submenu label="Actions" icon="ui-icon-gear">
<p:submenu label="Ajax" icon="ui-icon-refresh">
<p:menuitem value="Save" actionListener="#{menuBean.save}" icon="ui-icon-disk" update="messages"/>
<p:menuitem value="Update" actionListener="#{menuBean.update}" icon="ui-icon-arrowrefresh-1-w" update="messages"/>
</p:submenu>
<p:submenu label="Non-Ajax" icon="ui-icon-newwin">
<p:menuitem value="Delete" actionListener="#{menuBean.delete}" icon="ui-icon-close" update="messages" ajax="false"/>
</p:submenu>
</p:submenu>
<p:menuitem value="Quit" url="http://www.primefaces.org" icon="ui-icon-close" />
<f:facet name="options">
<p:inputText style="margin-right:10px"/>
<p:commandButton type="button" value="Logout" icon="ui-icon-extlink" />
</f:facet>
</p:menubar>
</h:form>
</h:body>
</html>
the output of the page is :Default Menubar
Note i get these sample from the prime faces tutorials page
Apparently you didn't include the PrimeFaces JAR file properly in the webapp's runtime classpath.
Here are the steps (well, step), you need to perform in a Dynamic Web Project in Eclipse in order to include a 3rd party JAR file properly in webapp's runtime classpath.
Drop the JAR file straight in project's /WEB-INF/lib folder.
That's all.
If you have ever fiddled around in project's Build Path properties in an attempt to achieve/fix it, then you need to make absolutely sure that you undo it all, or it may still cause conflicts/clashes.