0

i m using JSF2.0 and i m making one dataTable in that datatable i m getting the value from managed bean.And in managed bean in post construct annoted method i m calling my web service from another file.

Following is code for that

<h:dataTable
                    value="#{bean1.getList}" var="c" styleClass="order-table"
                    headerClass="order-table-header" width="100%" 
                    rowClasses="order-table-odd-row,order-table-even-row" rows="8"
                    columnClasses="first,second">

                    <h:column>
                        <f:facet name="header">
                            <h:selectBooleanCheckbox></h:selectBooleanCheckbox>
                        </f:facet>
                             <h:selectBooleanCheckbox value="#{c.id}"></h:selectBooleanCheckbox>

                    </h:column>

                    <h:column>
                        <!-- <f:facet name="header"/> -->
                        <h:outputLabel value="From: "></h:outputLabel>
                        <h:outputLabel value="#{c.from}"></h:outputLabel>
                        <br></br>
                        <!-- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -->
                        <h:outputLabel value="Sub: "></h:outputLabel>
                        <h:outputLabel  value="#{c.sub}"/>
                        <h:commandLink immediate="true" action="#{bean2.doRead}" value="Read" id="Read"></h:commandLink> 
                    </h:column>


                    <!-- Footer Setting -->
                    <f:facet name="footer">

                    </f:facet>
                </h:dataTable>

My Bean1 class

@PostConstruct
public void prepareList(){
{
        web service call

}

public List<InboxBean> getemailList(){
    return list;
}

Now when i m clicking on commandlink which has id Read at that time my bean1 post construct taged property also called. That i dont want to perform. So,how to get out from this problem and i also want to set the subject value in bean2 setProperty. Thanks in advance

Lumia
  • 121
  • 5
  • 13

1 Answers1

3

That can happen if the bean is put in request scope. Every single HTTP request will then reconstruct the bean. Put the bean in view or session scope instead.

E.g. in the view scope:

@ManagedBean
@ViewScoped
public class Bean {}

A view scoped bean lives as long as you're interacting with the same view by returning null or void in action methods.

Or in the session scope:

@ManagedBean
@SessionScoped
public class Bean {}

A session scoped bean lives as long as the established browser session. That is, from the very first HTTP request involving the bean until the client closes the entire browser instance or when the session expires on the server side (which defaults to 30 minutes).

For your particular case, a view scoped bean is most likely the best choice.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555