0

I am sorry, this might sound really basic but if anyone could explain how to set explicit values for every tabs in the same browser window using the JSF viewscoped bean.

Please guide me to some article or working samples.

Kindly help, thanks in advance

Update:

auth-page.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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:qumola="http://java.sun.com/jsf/composite/qumola"
    xmlns:p="http://primefaces.org/ui">
    <style type="text/css"/>
<h:panelGrid id="newGrid">
                            <ui:param name="labelResourceName"
                                value="#{userMenuState.selectedLeftMenuItem.menuLabel}" />
                            <h:form id="someForm">
                                <h:panelGrid id="topBannerId">
                                    <font>#{msg[labelResourceName]}</font> &nbsp;<font
                                        class="titleTextBar"> </font>
                                    <font class="titleTextBar">
                                        #{activityEditorManagedBean.selectedActivityBean.title}</font>
                                </h:panelGrid>
                            </h:form>
 </h:panelGrid>
</ui:composition>

The value "activityEditorManagedBean.selectedActivityBean.title" in the above code is a viewscoped bean variable value but it has the same value in every tab it is opened in.

Dinesh Kumar
  • 2,838
  • 1
  • 16
  • 18
  • You cannot do that. `@ViewScoped` is limited to a single view-tab. You need to use `@SessionScoped`. – Aritz Aug 29 '13 at 10:35
  • @XtremeBiker, FYI the view scope can very well be used in multiple tab requirements. I have got it to work in one another place. but it is not working properly here, some of the values are changed after refresh – Dinesh Kumar Aug 29 '13 at 10:43
  • You can use it for multiple tabs, but cannot share a value stored in a `@ViewScoped` bean across multiple tabs in the same browser. That's for sure. This is because `@ViewScoped` is designed to survive only for a related view. Check out this [link](http://stackoverflow.com/q/3202604/1199132) and look at BalusC's comment "Each tab has its own view scoped bean.". – Aritz Aug 29 '13 at 10:46
  • thats where the trouble lies? I get a common value in every tab. may because this page is used as a from another facelet. – Dinesh Kumar Aug 29 '13 at 10:54
  • Check out [this project](https://www.dropbox.com/s/fi2b35c9j14153i/view-testing.zip). I see you have Maven and eclipse tags in your records, so you could import it easily. – Aritz Aug 29 '13 at 13:23
  • Srry for the late reply. thanks wil look into it and get back to you – Dinesh Kumar Aug 29 '13 at 16:04
  • @XtremeBiker jus had a look into it. Clear explanation on the concept of view but nothing much on the UI perspective. The values is set in composition of multiple pages into one page. Maybe I will update the code. – Dinesh Kumar Aug 29 '13 at 16:14
  • This makes clear you have to go with `@SessionScoped`. I see no problem! – Aritz Aug 29 '13 at 16:32

0 Answers0