jsf-2

Distinguish ajax requests from full requests in JSF custom validator

五迷三道 提交于 2020-01-01 08:33:11
问题 My validator needs to know if it is a full request or an ajax request. In my current solution I check the http request header for the X-Requested-With element: public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); if (req.getHeader("X-Requested-With") != null) { // do something } else { // do something else } ... } Is there a better approach to achieve

Distinguish ajax requests from full requests in JSF custom validator

廉价感情. 提交于 2020-01-01 08:32:50
问题 My validator needs to know if it is a full request or an ajax request. In my current solution I check the http request header for the X-Requested-With element: public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); if (req.getHeader("X-Requested-With") != null) { // do something } else { // do something else } ... } Is there a better approach to achieve

Distinguish ajax requests from full requests in JSF custom validator

两盒软妹~` 提交于 2020-01-01 08:32:50
问题 My validator needs to know if it is a full request or an ajax request. In my current solution I check the http request header for the X-Requested-With element: public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); if (req.getHeader("X-Requested-With") != null) { // do something } else { // do something else } ... } Is there a better approach to achieve

dynamic ui:include with ui:fragment: component with rendered false still make inside component tree

与世无争的帅哥 提交于 2020-01-01 07:20:24
问题 I am force to use a very old version of MyFaces 2.0.5 I think, and dynamic include with EL cause so much problem, so I switch to static include with ui:fragment <ui:fragment rendered="#{filtersPopup.filterFileName == 'checkBoxFilters'}"> checkBoxFilters <ui:include src="/analytics/checkBoxFilters.xhtml" rendered="#{filtersPopup.filter != null}"/> </ui:fragment> <ui:fragment rendered="#{filtersPopup.filterFileName == 'DateRelativeFilter'}"> DateRelativeFilter <ui:include src="/analytics

What is the best way to pass data from page1 to page2 using the same backing bean?

谁都会走 提交于 2020-01-01 06:26:08
问题 I'm creating a simple search form on page1 and on page2 i will be showing the results. I'm wondering what the best way to do that with a @ViewScoped backing bean. Previously i've had to use @SessionScope to achieve this. Page1 - search page: <h:form id="documents"> <h4 class="dkblue u-case">Documents Search</h4> <h:outputLabel for="mainNum" value="mainNumber" /> <p:inputText id="mainNum" value="#{documentBacking.document.mainNumber}"/> <h:outputLabel for="secNum" value="secNumber" /> <p

How to validate the maximum amount of checked values of a selectManyCheckbox based on the current selection of a selectOneMenu?

情到浓时终转凉″ 提交于 2020-01-01 05:53:42
问题 I am using JSF 2.0 and PrimeFaces. I have a selectOneMenu and a selectManyCheckbox. I want to achieve this scenario: When an user chooses: option1(PieChart), then the user is allowed to check max one checkbox option2(BarChart), then the user is allowed to check max two checkboxes Here is my attempt so far, the view: <h:selectOneMenu value="#{bean.chartType}"> <f:selectItem itemValue="PieChart" itemLabel="PieChart" /> <f:selectItem itemValue="BarChart" itemLabel="BarChart" /> <p:ajax event=

Is it possible to use container-managed authentication with password salting?

夙愿已清 提交于 2020-01-01 05:42:06
问题 I know how to set up vanilla container-managed security that uses form authentication and uses digested passwords (say, SHA-256). Something like this: web.xml <login-config> <auth-method>FORM</auth-method> <realm-name>jdbc</realm-name> <form-login-config> <form-login-page>/login.jsf</form-login-page> <form-error-page>/login-error.jsf</form-error-page> </form-login-config> </login-config> login.xhtml <form action="j_security_check"> <p><label> Username:<br/> <input type="text" name="j_username

JSF2 managed bean annotation + scope + injection confusion

南楼画角 提交于 2020-01-01 05:37:08
问题 I would like to achieve this idealism : To have only 1 implementation for the JSF Bean container, like to use only Spring or Weld but not both. Currently i am using Spring for my backend, so i prefer Spring. To have only 1 annotation, to choose between @ManagedBean, @Named, @Model To be able to use all supported scopes, like @RequestScoped, @SessionScoped, @ViewScoped, @FlashScoped, maybe also @ConversationScoped The JSF Beans could be injected with spring-managed-services (The backend

Confusing Tomcat Persistent Session Memory Profile

本小妞迷上赌 提交于 2020-01-01 05:27:08
问题 As with any memory management issue, this is a long story, so strap-in. We have an application that has been suffering from some memory management issues, so I've been trying to profile the app to get an idea of where the problem lies. I saw this thread earlier today: Tomcat Session Eviction to Avoid OutOfMemoryError ... which seems to follow suit with what I was seeing in the profiler. Basically, if I hit the app with a bunch of users with Jmeter it would hold onto the heap memory for a long

PRIMEFACES - How to refresh a <p:graphicImage> from clicking a <p:commandButton>?

a 夏天 提交于 2020-01-01 05:06:34
问题 I'm considering this showcase: http://www.primefaces.org/showcase/ui/dynamicImage.jsf in particular the sub-case "GraphicText on-the-fly". My problem is implementing an extended version of this sub case with the addition of a . When the button is pressed i need that the image change dinamically. In the DynamicImageController class I re-writed the getter associeted with the graphicImage: public StreamedContent getGraphicText(){ double random = Math.random();// a double value with a positive