开发者

Various Questions about JSF

开发者 https://www.devze.com 2023-02-09 03:10 出处:网络
i\'m doing a JSF2 project. 1 . i have a form with some checkbox. Look the following code <ui:repeat>

i'm doing a JSF2 project.

1 . i have a form with some checkbox. Look the following code

<ui:repeat>
<h:selectManyCheckbox value="#{wagent.selectedPra}">...
</h:selectManyCheckbox>
</ui:repeat>

So i use selectManyCheckbox inside ui:repeat and i want that the value of the different selectManyCheckbox point to the same value. But when the form is submit i didn't have all the selected boxs. How i can do that ?

2 . I have a form with some inputs. On my action i want to merge some pdf files, stay on the same page and that a pop-up appear to offer to download the merged files.

3 . Does all the managed beans with request scope are created for each reques开发者_开发知识库t or just if i used them in the xhtml page?

4 . I have a commandlink to logout. On my action i use session.invalidate() and return "login". So i go back to the login, but when validating the login, my session managed bean doesn't seem to be created. Error is something like yourSessionBean is null. What's wrong ?


1: So i use selectManyCheckbox inside ui:repeat and i want that the value of the different selectManyCheckbox point to the same value. But when the form is submit i didn't have all the selected boxs. How i can do that ?

Let them point to a different value instead. With the given example the bean value will be overridden everytime until end of the loop. As an example, use a List<List<Pra>> in a bean (or whatever Pra means in your question):

<ui:repeat value="#{wagent.allSelectedPra}" var="selectedPra">
    <h:selectManyCheckbox value="#{selectedPra}">
        ...
    </h:selectManyCheckbox>
</ui:repeat>

2: I have a form with some inputs. On my action i want to merge some pdf files, stay on the same page and that a pop-up appear to offer to download the merged files.

At least two things needs to be done:

facesContext.getExternalContext().addResponseHeader("Content-Disposition", "attachment;filename=name.pdf"); // Force "Save As" dialogue.
facesContext.responseComplete(); // Prevent JSF from taking response in hands.

3: Does all the managed beans with request scope are created for each request or just if i used them in the xhtml page?

They are created for every HTTP request. The scope which you described only applies on view scope (if I understand you right).

4: I have a commandlink to logout. On my action i use session.invalidate() and return "login". So i go back to the login, but when validating the login, my session managed bean doesn't seem to be created. Error is something like yourSessionBean is null. What's wrong ?

You are probably accessing the session scoped managed bean the wrong way. You need to either inject it as @ManagedProperty or to grab it by Application#evaluateExpressionGet().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号