jsf-2

How to use JSF versioning for resources in jar

末鹿安然 提交于 2019-12-17 10:54:33
问题 PF 3.5.10, Mojarra 2.1.21, omnifaces 1.5 I have a JSF library (with css files only). This library is in a .jar file. The css will be included in xhtml with <h:outputStylesheet library="mylib" name="css/mycss.css"> . In html it is rendered to the following: localhost:8080/cms/javax.faces.resource/css/mycss.css.jsf?ln=mylib CSS file of primefaces is rendered to: localhost:8080/cms/javax.faces.resource/primefaces.js.jsf?ln=primefaces&v=3.5.10 Notice the library version (&3.5.10) at the end. How

@PreDestroy never called on @ViewScoped

只愿长相守 提交于 2019-12-17 10:50:11
问题 I have a @ViewScoped bean that has a method with an @PreDestroy annotation that should make sure some remote connections are closed. However, the method is not called when the user navigates away. Is there anything one can do wrong? Do I have to register anything anywhere in order to make it work? It's a simple public method ( void ) that throws no exception. I'm using JSF 2 (MyFaces) with Tomcat 7.0.12. Could it be a problem with Tomcat? UPDATE The @PostConstruct annotation works fine. 回答1:

Prevent accessing restricted page without login in Jsf2

六眼飞鱼酱① 提交于 2019-12-17 10:46:46
问题 I have a problem. I want to prevent a user from accessing a page without login in jsf2. When a user directly write restricted page url into browser, s/he should not see the page. Thats like above circumstance come about, s/he has to be redirected to login page. How can I do this programmatically ? 回答1: That depends on how you have programmed the login. You seem to be using homegrown authentication wherein you set the logged-in user as a property of a session scoped managed bean. Because with

How to include JavaScript files by h:outputScript? [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-17 10:46:22
问题 This question already has answers here : How to reference CSS / JS / image resource in Facelets template? (4 answers) Closed 3 years ago . I want to use jQuery Validate plugin with JSF for client side form validation. I am finding basic difficulty in importing the resources. In my JSF page I have <h:outputScript library="js" name="jquery-1.6.2.js"></h:outputScript> <h:outputScript library="js" name="jquery.validate.js"></h:outputScript> <h:outputScript library="js" name="jquery.maskedinput.js

Keep <p:dialog> open when validation has failed

Deadly 提交于 2019-12-17 10:42:38
问题 I have a CRUD page which shows data from a query (a List of domain objects) in a Primefaces datatable. <p:dataTable id="negozi" var="n" value="#{nController.theListFromQuery}" rowKey="#{n.id}" selection="#{nController.selected}" selectionMode="single"> <p:column headerText="Field1"> <h:outputText value="#{n.f1}" /> </p:column> <p:column headerText="Field2"> <h:outputText value="#{n.f2}" /> </p:column> <p:column style="width:4%"> <p:commandButton actionListener="#{nController.prepareEdit(n)}"

How to set maxlength attribute on h:inputTextarea

点点圈 提交于 2019-12-17 09:42:19
问题 How can I limit the length of <h:inputTextarea> ? For <h:inputText> it works fine with maxlength attribute. However, this attribute is unavailable in <h:inputTextarea> . 回答1: HTML5 + JSF 2.2+ If you're using HTML5 and JSF 2.2+, specify it as a passthrough attribute. <html ... xmlns:a="http://xmlns.jcp.org/jsf/passthrough"> <h:inputTextarea value="#{bean.text}" a:maxlength="2000" /> HTML5 + JSF 2.0/2.1 If you're using HTML5, but not JSF 2.2 yet, use OmniFaces Html5RenderKit to recognize new

Pass Argument to a composite-component action attribute

点点圈 提交于 2019-12-17 08:53:36
问题 The title really says it all. I have made an attempt which failed with the error: Illegal attempt to pass arguments to a composite component lookup expression (i.e. cc.attrs.[identifier]). My attempt looks like this: <composite:interface> <composite:attribute name="removeFieldAction" method-signature="void action(java.lang.String)" /> </composite:interface> <composite:implementation> <h:commandButton value="Remove" action="#{cc.attrs.removeFieldAction('SomeString')}"/> </composite

Is it possible to disable f:event type=“preRenderView” listener on postback?

别来无恙 提交于 2019-12-17 07:26:46
问题 Is it possible to "disable" triggering of this action when doing postback? <f:metadata> <f:event listener="#{defaultNewQuestionHandler.init}" type="preRenderView" /> </f:metadata> 回答1: That's not possible with <f:event> . You need to manually check FacesContext#isPostback() inside the listener method. public void init() { if (!FacesContext.getCurrentInstance().isPostback()) { // ... } } In the upcoming JSF 2.2 <f:viewAction> tag, which is supposed to replace this <f:event type="preRenderView"

what to use, managed beans (backing beans) or entity beans?

本小妞迷上赌 提交于 2019-12-17 07:25:32
问题 I see a lot of examples marking beans as entity beans (@Entity) & named beans (CDI), so as to avoid creating 2 classes (managed bean & entity bean) and also to make use of Bean Validation so that validation can be performed on both client & server. So should I be using a single class or not, are there any issues or should I be having my managed beans or service layer create entity beans using the data from managed beans ? 回答1: The @Named or @ManagedBean annotations are typically used to let

Error Parsing /page.xhtml: Error Traced[line: 42] The entity “nbsp” was referenced, but not declared

久未见 提交于 2019-12-17 07:13:09
问题 I'd like to use non breaking spaces in my JSF page. I know, in plain HTML I could use   for this and this works fine. However, when I put those   in a Facelets page, then it errors as follows: Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared. How is this caused and how can I solve it? 回答1: Facelets is a XML based view technology. XML has only five predefined entities. The   is not among them. It works only when used in plain HTML or in