Pop up Window in spring web flow - jsf

i am still new to spring.I need to make a popup window when the button is clicked in spring web flow.
Let say in html file
<h:commandLink value="Sick Leave" action="sickleave" id="sickleave" /></div>
When the action command link is clicked I have to populate the page with some value on-entry itself.
In my flow.xml
<transition on="sickleave" to="sickLeave"></transition>
<view-state id="sickLeave" view="sickLeave.xhtml" popup="true"></view-state>
i have added popup=true.But still i am not able to get a popup window.

I think you need a to use a sf:commandLink component instead of the h:commandLink setting the reRender tag as follows:
<sf:commandLink value="Sick Leave" action="sickleave" reRender="#{flowRenderFragments}" processIds="*" id="sickleave" />
I'm not sure if the "processIds" tag is needed, so try it with and without it.

Related

Display Primefaces's OverlayPanel when the page loads

The page shows a Primefaces's overlayPanel when the target component (a commandButton) is clicked on:
<p:commandButton id="inputBtn" value="Choose a data source" type="button" action="#{dataImportBean.oAuth}"/>
<p:overlayPanel
id="overlaypanel1"
for="inputBtn"
dynamic="false"
widgetVar="inputChooser"
>
// contents of the overlay panel
</p:overlayPanel>
I would need the overlayPanel to be displayed when the page loads, without the need to click on the target commandButton.
The use case is: the user had the overlayPanel opened but an oAuth flow made the user navigate away from the page. When the oAuth is completed the user is redirected to the page. However the overlayPanel is closed when the page loads, whereas I need the user to be brought back directly to the overlayPanel, for consistency.
Use the client side API on your widget var. You can use show() to show the panel, so in your case: PF('inputChooser').show().
To do this on page load, you could place this after the p:overlayPanel:
<c:if test="#{yourCondition}">
<script>$(function() { PF('inputChooser').show() })</script>
</c:if>
See also:
https://primefaces.github.io/primefaces/10_0_0/#/components/overlaypanel?id=client-side-api

JSF 1.2 to open external link in new tab. without distrubing current flow [duplicate]

I need to open a JSF page in a new window by POST on click of a <h:commandButton>. I know I can acheive this using the JavaScript. But I would like to achive this using JSF and not JavaScript.
How can I achieve this? I'm using JSF 2.0.
The only non-JS way is to set target="_blank" in the parent <h:form>.
<h:form target="_blank">
...
<h:commandButton value="Open in new Window" />
</h:form>
This however affects all non-ajax(!) actions which are performed in the very same form. So if you're smart, make the action which shouldn't open in a new window an ajax action. However, ajax is also JavaScript and you mentioned that you don't want to use JS (I hope you don't get shocked once you discover that PrimeFaces is actually full of JavaScript).
If you absolutely need to restrict it to a single action, then you really can't go around asking little help to JavaScript.
<h:form>
...
<h:commandButton value="Open in new Window" onclick="this.form.target='_blank'" />
</h:form>
When you restrict the target only to a single action, maybe you want to get the form in its initial state.
With the oncklick action you set the target of the form to a _blan page.
After the click, the page is opened in a new tab/page (triggers the action event).
At last, the onblur action is triggered and set the form again to its initial state (the rest of the buttons will open in the _self page)
With this code, you can restrict to only a h:commandbutton to open in a new page.
The rest of the buttons will be opened in the self page:
<h:commandButton
onclick="this.form.target='_blank'"
onblur="this.form.target='_self'"
id="listadoRebuts"
action="#{giaquaBusquedaCorte.abrirListadoRebuts}"
value="#{msg.seqVisorbtnRecibos}">
</h:commandButton>

Pressing enter to click on hidden button without using JS on a jsf page?

I have a jsf page where I have several 's. When I press enter I want a particular button to be clicked - and this button is hidden. Is there a way to do this without using JS?
I know if i place the button as the first button on the page, it will be clicked by default - but it does not seem to work.
Here is the sample code. I want the "hiddenButton" to be clicked on Enter.
<h:form>
<h:commandButton id="button1" action="#{bean.action1}" />
<h:commandButton id="button2" action="#{bean.action2}" />
<h:commandButton id="button3" action="#{bean.action3}" />
<h:commandButton id="hiddenButton" action="#{bean.hiddenAction}" style="display:none;"/>
<h:form>
Is there a way to do this without using JS?
Not if you want to support all browsers.
I know if i place the button as the first button on the page, it will be clicked by default - but it does not seem to work.
This works only in Firefox, not in Chrome (Webkit) or IE. If you replace display:none by visibility:hidden, then it'll also work in Chrome, but still not in IE.
So, if you want to support all browsers, JS is your best bet. There may be better solutions depending on the concrete functional requirement, which you didn't tell anything about in the question.

Messages not displayed on modal panel

I got a Problem displaying messages on a modal panel using Spring Webflow and Richfaces. The Messages a published to the Message Context in my action, without a component-id. This works fine on my main page, but if I open a rich:modalPanel and click a button there the Message is not displayed.
Can anybody give me a hint why this happens? Do modal panels not support <rich:messages global="true"/>
My button looks like:
<a4j:commandButton
id="add"
action="add"
value="#{resourceBundle['button.add']}"
reRender="adPopupPanel"/>
My messages-tag like:
<rich:messages globalOnly="true"/>
Add attributes to your message tag such as showSummary and ShowDetail and set them as true.

Open new window by POST using h:commandButton

I need to open a JSF page in a new window by POST on click of a <h:commandButton>. I know I can acheive this using the JavaScript. But I would like to achive this using JSF and not JavaScript.
How can I achieve this? I'm using JSF 2.0.
The only non-JS way is to set target="_blank" in the parent <h:form>.
<h:form target="_blank">
...
<h:commandButton value="Open in new Window" />
</h:form>
This however affects all non-ajax(!) actions which are performed in the very same form. So if you're smart, make the action which shouldn't open in a new window an ajax action. However, ajax is also JavaScript and you mentioned that you don't want to use JS (I hope you don't get shocked once you discover that PrimeFaces is actually full of JavaScript).
If you absolutely need to restrict it to a single action, then you really can't go around asking little help to JavaScript.
<h:form>
...
<h:commandButton value="Open in new Window" onclick="this.form.target='_blank'" />
</h:form>
When you restrict the target only to a single action, maybe you want to get the form in its initial state.
With the oncklick action you set the target of the form to a _blan page.
After the click, the page is opened in a new tab/page (triggers the action event).
At last, the onblur action is triggered and set the form again to its initial state (the rest of the buttons will open in the _self page)
With this code, you can restrict to only a h:commandbutton to open in a new page.
The rest of the buttons will be opened in the self page:
<h:commandButton
onclick="this.form.target='_blank'"
onblur="this.form.target='_self'"
id="listadoRebuts"
action="#{giaquaBusquedaCorte.abrirListadoRebuts}"
value="#{msg.seqVisorbtnRecibos}">
</h:commandButton>

Resources