Java EE vs JSP vs JSF [closed]

Is JSP “dead” in favor of JSF? JSF has countless benefits over JSP. For instance: It defines a MVC approach It set up componentization standards It has apply values feature Built-in AJAX A defined view context control Allows for rich interfaces extensions like Primefaces And we can go on and on. You can still use … Read more

How to trigger component refresh from javascript in primefaces?

You can use PrimeFaces’ <p:remoteCommand> for this. <p:remoteCommand name=”updateGrowl” update=”showmessage” /> which is to be invoked as <p:commandButton … oncomplete=”addMemberDlg.hide(); updateGrowl();” /> In this particular case there’s however a simpler way. Set the autoUpdate attribute of <p:growl> to true. <p:growl autoUpdate=”true” life=”1500″ id=”showmessage”/> It’ll auto-update itself on every ajax request. If your component actually didn’t … Read more

Understand Flash Scope in JSF2

In short, variables stored in the flash scope will survive a redirection and they will be discarded afterwards. This is really useful when implementing a Post-Redirect-Get pattern. If you try to navigate to another page by redirect and access the attributes on load, they will be there. After that request is done the values in … Read more

How can I get a message bundle string from inside a managed bean?

You can get the full qualified bundle name of <message-bundle> by Application#getMessageBundle(). You can get the current locale by UIViewRoot#getLocale(). You can get a ResourceBundle out of a full qualified bundle name and the locale by ResourceBundle#getBundle(). So, summarized: FacesContext facesContext = FacesContext.getCurrentInstance(); String messageBundleName = facesContext.getApplication().getMessageBundle(); Locale locale = facesContext.getViewRoot().getLocale(); ResourceBundle bundle = ResourceBundle.getBundle(messageBundleName, … Read more

How to dynamically add JSF components

Use an iterating component like <h:dataTable> or <ui:repeat> to display a dynamically sized List of entities. Make the bean @ViewScoped to ensure that the list is remembered across postbacks on the same view instead of recreated over and over. Kickoff example with <h:dataTable> (when using <ui:repeat> simply replace <h:dataTable> by <ui:repeat>, and <h:column> by e.g. … Read more

How to detect current JSF-Version?

Programmatically, you mean? You can get it from Package#getImplementationVersion(). String version = FacesContext.class.getPackage().getImplementationVersion(); There are by the way also getImplementationVendor() and getImplementationTitle() methods. You might want to use it as well in order to distinguish the vendor (MyFaces or Mojarra, for example). Or do you mean manually? Just look in /META-INF/MANIFEST.MF file of the JSF … Read more

Why prependId=”false” in a jsf form?

In my experience, I never use this attribute. However, in some cases it can be useful. When you use Facelets, you can create templates or include pages inside another page. So you can imagine that a page could be included in several different pages. Take the example where the parent pages contain a form, with … Read more

What is the function of @this exactly?

The PrimeFaces process and standard JSF execute attributes should point to spaceseparated component identifiers of components which JSF should process during the entire JSF lifecycle upon an ajax request (get request parameters, validate them, update model, execute action). The process defaults to @form, the current form, and the execute defaults to @this, the current component. … Read more

How to do double-click prevention in JSF

If you’re using solely ajax requests, you could use jsf.ajax.addOnEvent handler of the JSF JavaScript API for this. The below example will apply on all buttons of type=”submit”. function handleDisableButton(data) { if (data.source.type != “submit”) { return; } switch (data.status) { case “begin”: data.source.disabled = true; break; case “complete”: data.source.disabled = false; break; } } … Read more

techhipbettruvabetnorabahisbahis forumu