[JBoss Seam] - Re: JSF/Seam Binding and Nested Classes
by aggtecnologia
In the first code snippet please ignore the annotation @Stateful. It is just a typo (it s not in my code). My code is just:
| @Entity
| @Name("mother")
| public class Mother {
|
| private Daughter daughter;
|
| ... setters and getters
| }
|
I found a workaround defining Daughter as a Seam component:
| @Name("daughter")
| public class Daughter {
|
| private String someprop;
|
| ... setters and getters
|
| }
|
and then using it as a separate component and asociating it with mother in Java:
I mean instad of using:
| <h:inputText value="#{mother.daughter.someprop}"/>
|
I use:
| <h:inputText value="#{daughter.someprop}"/>
|
and then in the action bean:
|
| @Stateful
| public class ActionBean {
| ....
|
| @In
| private Mother mother;
|
| @In
| private Daughter daughter;
|
| public void persistMother () {
|
| mother.setDaughter(daughter);
|
| em.persist (daughter);
|
| }
|
| ....
| }
|
It is not elegant but at least it works.
Nevertheless I would like to know if there is any bug in the Expression Language interpreter or if I am doing something wrong. Accortding to JSF specification the first sintax I mention should work.
any comments?
Thanks in advnace.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121528#4121528
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4121528
18 years, 5 months
[JBoss Seam] - Re: Problem with validation and entityHome
by fjgarmu
Thanks for ur reply matt.drees.
I try writing a new method mysave in ReportsHome:
| public String mysave(){
| if (this.getInstance().getRadiologos().getId()==0 && this.getInstance().getReportstatus().getId()>=4){
| this.addFacesMessage("ERROR");
| return "error";
| }else{
| super.update();
| return null;
| }
| }
|
In the JSF page the method is called by a <s:button>
| <s:button id="mysave"
| value="mysave"
| action="#{reportsHome.mysave}"
| view="/Reports.xhtml"
| rendered="#{reportsHome.managed}"/>
|
The behaviour is: the values are saved even when the ERROR message is raised and the application goes to "Reports.xhtml" page, even when the parameters aren't valid and the super.update method is not called.
Why?
How could I do it for don't save it when the values are not correct?
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121526#4121526
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4121526
18 years, 5 months