[JBoss Seam] - Seam Gen messages
by fady.matar
I have been playing around with Seam Gen, and I liked the approach and the source code generation is way better than the one by the previous Seam wizard by Hibernate tools.
I have a few questions to raise, I have updated one of the classes of my Entity Bean and update the persist and the update method since one of the fields is unique and I don't want to be redirected to the debug page.
The update was simple and I don't believe it is the right approach. Here's my code for the two methods.
| @Override
| public String persist() {
| try {
| return super.persist();
| } catch (Exception ex) {
| return null;
| }
| }
|
| @Override
| public String update() {
| try {
| return super.update();
| } catch (Exception ex) {
| return null;
| }
| }
|
Now I'm not redirected to the debug page, and a message Transaction Failed appears.
Here's the custom message I have added to provide more feedback about the error to the end user:
| @Override
| public String persist() {
| try {
| return super.persist();
| } catch (Exception ex) {
| FacesMessages.instance().clear();
| FacesMessages.instance().add(
| "The name you has already been reserved.");
| return null;
| }
| }
|
| @Override
| public String update() {
| try {
| return super.update();
| } catch (Exception ex) {
| FacesMessages.instance().clear();
| FacesMessages.instance().add(
| "The name you has already been reserved.");
| return null;
| }
| }
|
I would like to take the "Transaction Failed" message and replace it with one specified above. The clear method did not take it out.
Any suggestions?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4010576#4010576
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4010576
19Â years, 2Â months
[JBoss Seam] - Re: dataTable in two windows
by lightbulb432
anonymous wrote : First problem can be solved by passing the id as a request parameter instead of blindly using @DataModelSelection.
Could anybody please explain how they've done this with their code?
The code below explains how to remove the appropriate entity when you have a request parameter passed in. But how can I make every row in the dataTable output a corresponding request parameter (so that when someone clicks a link in the table, the request parameter gets passed)?
@RequestParameter
| Long entityId;
|
| public void removeMyEntity() {
| MyEntity mySelectedEntity = em.find(MyEntity.class, entityId);
| em.remove(mySelectedEntity);
| }
Is it as simple as an h:commandLink to the action method with a nested f:param that has the id of the entity?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4010560#4010560
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4010560
19Â years, 2Â months