JSF property transfer from backing bean A to backing bean B

I'm getting deeper into JSF 2.0 at the moment and lacking a bit of understanding about the "transport" of managed bean properties from one view to the other. I searched a bit but haven't found a really good example, so if anyone could point me to a tutorial or explain the things a little bit I'd really grateful. So here is my scenario: I'm developing a small playground calendar application. The first view select.xhtml contains the calendar selector, where the user can pick a specific date: ... ... My corresponding backing bean looks like this: @ManagedBean(name="calendarSelect") @RequestScoped public class CalendarSelectComponent { private Date date = null; ... // Getters and setters Now when I submit the form from select.xhtml I'm forwarded to day.xhtml ... The current day ist: The backing bean now looks like this: @ManagedBean(name="calendarEdit") @ViewScoped public class CalendarEditComponent implements Serializable { private Date date = null; private CalendarEntryBean currentEntry = null; private List allEntries = null; .... I am now trying to solve the problem: How do I transfer the date parameter from the _selector_ to the _editor_? I've tried a number of options, one was this: A debugger shows, that indeed, the date property of the calendarEdit is populated with the value from calendarSelect, but since day.xhtml is a new view, a new CalendarEditComponent backing bean is being created and not the one I've populated with the date from the selector in the select view. I've read that one solution would be to create a SessionScoped backing bean that does retain all it's values. But this is not the way I think it's supposed to work, because I don't really need the information in the *session*, I simply want it to "travel" from A to B. Another downside with the session based approach is that I can only use one selector and one editor per session - which I think isn't acceptible if you think of multi window browsing and so on. I really don't think I'm the first one encountering such a scenario and I'm sure that JSF provides an elegant solution for this but I haven't been able to find that solution. So once again, if anyone knows how to approach this - I'm listening! ;-)

以上就是JSF property transfer from backing bean A to backing bean B的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准