0
votes

we are new to JSF and are struggling with the following problem.

we have a search page, where a user can click on a button to go to a detail page. When arriving on this detail page the selected record is shown correctly.

When the user edits the value, a validator kicks in. The custom validator checks 2 things: -if the record is already in the DB (unique) -if the value is not empty

When the user removes the current value, to an empty string, submits, the validator says the value is not allowed to be empty.

When the user changes back the value to the previous value, and submits, the validator should validate the current value and go back to the search page.

Now the problem is the following: When using:

<h:outputLabel value="Supplier Id" />
<h:outputLabel value="#{flash.keep.supplier.id}" />

everything works. But we would like to hide the id from the user and use a hidden field.

When removing the outputLabel , and using:

<h:inputHidden value="#{flash.keep.supplier.id}" />

our application thinks we are trying to insert a new supplier instead of saving the already existing supplier, with the same name.

We are using JSF 2.0, GlassFish Server 3.1.2 in a NetBeans development environment.

The beans are RequestScoped

The source code is available on: https://bitbucket.org/dasdan20/timereg4wb-web

The views are in : Web/suppliers/search.xhtml Web/suppliers/addedit.xhtml

The beans and backing code in: src/task/SupplierTask.java src/task.validation/SupplierUniqueValidator src/domain/Supplier.java

The DB backend is MySQL: a backup of the DB can be found in: src/MySQLDatabase

Thanks in advance

K & K

1
So, the user changed supplier or w/e and it's time to go back to search page. Whats the function of the hiddeninput? If you want to save something perhaps use a bean with a longer scope?Karl Kildén
the reason we actually have to place an updatelabel or hiddeninput is otherwise it seems our application doesn't remember the "choosen supplier" from the search page.timereg4wb

1 Answers

0
votes

You are doing it wrong probably. Make a new Bean with a longer scope to "remember" choosen supplier.

@RequestScoped
SupplierController
// Almost everything here

@SessionScoped
StatefulSupplierController
// State that needs to be saved