jsf-2

h:selectOneMenu required=“true” reverts to bean value on validation failure

十年热恋 提交于 2019-12-31 03:48:27
问题 I have something like this on a create/edit form: <h:selectOneMenu value="#{bean.value}" required="true" ... > <f:selectItem itemLabel="-- Select --" itemValue=""/> <f:selectItems .../> </h:selectOneMenu> In the create new object case, the required validation works as expected. In the edit object case, if I change a valid value to the placeholder "-- Select --", I get the validation failure w/expected requiredMessage because itemValue is blank (""); however , the HTML <select> reverts to

JSF ajax request is not fired when combined with JS client-side validation

爱⌒轻易说出口 提交于 2019-12-31 03:30:48
问题 I'm using JSF 2.0 and primefaces. I have one page with several inputs inside a form and a button that adds a new record to a table using ajax. Everything works ok. Then I added client side validation using JavaScript. This is the code of the command button: <p:commandButton value="Add" actionListener="#{reqAbsences.addPreLeaveDemand}" onclick="return validateNewAbs()" update="tableForm inputForm errorForm" /> If validation fails, it works as expected and the record is not added no the table.

JSF commandButton - passing POST params to an external site

久未见 提交于 2019-12-31 03:16:07
问题 I need a link which redirect me to a different site and send POST parameters. Something like: <h:form> <h:commandButton value="submit" action="http://example.com"> <f:param name="user" value="robson"> </h:commandButton> </h:form> The code above doesn't work of course. I'd like to acheive this in HTML: <form action="http://example.com" method="POST"> <input type="hidden" name="user" value="robson"> <input type="submit" value="submit"> </form> Is that possible? 回答1: Use the vanilla HTML <form>

JSF - Ajax call - What is it wrong on this code?

霸气de小男生 提交于 2019-12-31 02:20:15
问题 I think the best way to resolve this problem is just to paste my code : Selector bean @ManagedBean(name="selector") @RequestScoped public class Selector { @ManagedProperty(value="#{param.page}") private String page; private String profilePage; @PostConstruct public void init() { if(profilePage==null || profilePage.trim().isEmpty()) { this.profilePage="main"; } if(page==null || page.trim().isEmpty()) { this.page="homepage"; } } public String getProfilePage() { System.out.println("GET ="

JSF calling setter & getter multiple times

老子叫甜甜 提交于 2019-12-31 02:19:07
问题 I am using JSF 2.0. I don't want to call setter & getter multiple time. Can you help me to avoid that? 回答1: Why is that bothering you? Those calls are extremely cheap. Perhaps you're incorrectly invoking expensive business logic in getters/setters instead of in (post)constructor and/or action(listener) methods? That's indeed a very common starter's mistake in JSF. Just don't invoke business logic in getters/setters. Invoke business logic in (post)constructor and/or action(listener) methods

Using composite:insertFacet/renderFacet does not work inside t:dataTable

别说谁变了你拦得住时间么 提交于 2019-12-31 00:44:53
问题 I'm doing this: resources/vm/table.xhtml: ... <composite:interface> <composite:facet name="dataBody" required="true"/> </composite:interface> ... <composite:implementation> <t:dataTable> <composite:renderFacet name="dataBody"/> </t:dataTable> </composite:implementation> ... And in page.xhtml: ... <vm:table> <f:facet name="dataBody"> <t:column> Testing. </t:column> </f:facet name="dataBody"> </vm:table> ... Problem: The 'dataBody' facet is not rendered. In JSF1.2 I used to do this with ui

Jsf2.0 forwarding page error without parameter

家住魔仙堡 提交于 2019-12-30 18:56:07
问题 Hello i have error when i am forwarding page without parameter. that is happen only in constructor. not happening with methods. like public EditNewsBean() throws Exception { log.info("In EditNewsBean Constructor"); Object o1=request.getParameter("countryCode"); Object o2=request.getParameter("editNewsID"); if(o1==null || o2==null || o1.toString().length()==0 || o2.toString().length()==0) { FacesContext.getCurrentInstance().getExternalContext().redirect("/HeWebEV/admin/ManageNews.jsf"); }

“This link is deactivated, because it is not embedded in a JSF form.”

霸气de小男生 提交于 2019-12-30 18:26:22
问题 When I use the following command link: <h:commandLink action="student" value="students" /> And the following navigation rule in faces-config.xml : <navigation-rule> <from-view-id>/home.xhtml</from-view-id> <navigation-case> <from-outcome>student</from-outcome> <to-view-id>/student.xhtml</to-view-id> </navigation-case> </navigation-rule> Then I get the following development stage faces message: This link is deactivated, because it is not embedded in a JSF form. How is this caused and how can I

java.lang.VerifyError: org/primefaces/behavior/confirm/ConfirmBehaviorHandler Wrong return type in function

馋奶兔 提交于 2019-12-30 17:59:27
问题 This morning (South African time), Maven downloaded the latest primefaces jar (version 5.3). While my project is setup in a manner that maven deploys the project to my Web Container (in this case, Wildfly 9.0.1.Final), it failed deployment due to the following exception: 2015-10-19 09:52:36,696 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 82) Critical error during deployment: : java.lang.VerifyError: (class: org/primefaces/behavior/confirm

javax.faces.FacesException: Could not resolve NavigationCase for outcome

谁都会走 提交于 2019-12-30 17:26:29
问题 I have one template.xhtml file at /template/template.xhtml <h:head> </h:head> <h:body> <p:layout fullPage="true"> <p:layoutUnit position="north" size="100"> <h:outputText value="header"></h:outputText> </p:layoutUnit> <p:layoutUnit position="center"> <p:layout> <p:layoutUnit position="north"> <h:outputText value="tabs"/> <ui:include src="/tabs/tabs.xhtml"/> </p:layoutUnit> <p:layoutUnit position="west"> <h:outputText value="left menu"></h:outputText> </p:layoutUnit> <p:layoutUnit position=