Problem with MyDaces CODI and windowId query parameters

I tried to run some simple tests on Seam Weld and MyFaces CODI . After adding the CODI jar files to my projects, I found that it adds the windowId request value for every request, even if the scope bean is RequestScoped . Is it really necessary to add the windowId parameter for each request and the bean to the RequestScoped ? Is there any practical real-world scenario for this case? Can I remove it if I don't need it? For example:

This is the bean class code:

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named("myBean")
@RequestScoped
public class MyBean{
private String firstName;
private String lastName;

public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}
}

      

This is the body of the page:

<body>
<h:form>
<h:inputText value="#{myBean.firstName}"></h:inputText>
<br/>
<h:inputText value="#{myBean.lastName}"></h:inputText>
<br/>
<h:commandButton value="submit"></h:commandButton>
</h:form>
</body>

      

+1


source to share


2 answers


Apache MyFaces CODI adds windowId to support browser tab with split beans. If you are using some CODI scopes like @WindowScoped, @ViewAccessScoped, CODIs @ConversationScoped then you will get a separate context instance for each browser tab.

Suppose you have a customer relationship management application. With CODI @WindowScoped you can open different clients in different browser tabs / windows. Are you using @SessionScoped then you will be overwriting the values ​​every time (there is only 1 context instance for @SessionScoped beans for each session).



And of course, you can easily disable this feature. Please check out our official WIKI: https://cwiki.apache.org/confluence/display/EXTCDI/Index

+3


source


It takes a while to find a solution on the official wiki. https://cwiki.apache.org/confluence/display/EXTCDI/Index

If you are not using @WindowScoped, @ViewAccessScoped and are sure that you do not need this windowId parameter, you can create a class like this in your project:



@Specializes
@ApplicationScoped
public class CustomWindowContextConfig extends WindowContextConfig {

    @Override
    public boolean isAddWindowIdToActionUrlsEnabled() {
        return false;
    }

    @Override
    public boolean isUrlParameterSupported() {
        return false;
    }
}

      

+3


source







All Articles