Spring Webflow - access exception using transition.on-exception attribute - exception

I wondering how can I access exception object using on-exception attribute?
My current configuration looks like this:
<transition on-exception="{business_exception}" to="errorView" >
</transition>
I have to access some exception attribute in errorView.
Does anybody know how can I do it?

This is a rather undocumented part of Spring Web Flow, but according to this thread on SpringSource forum, you can access the exception directly on your view as attributes stateException and rootCauseException.

rootCauseException and flowExecutionException are the right scoped variables that are accessible in the flow. These variables are populated after the transition to the new flow,so in a pseudo sense:
<transition on-exception="{business_exception}" to="errorView" >
</transition>
<view-state id="errorView">
<on-entry>
<evaluate expression="exceptionHandler(flowExecutionException)"/>
<evaluate expression="exceptionHandler(rootCauseException)"/>
</on-entry>
</view-state>

Related

Can't apply plain HTML class to a Blazor component

I've tried to use this code in my .NET 5 Blazor project, in .razor file:
<SignedLabel class="some-css-class" Price=123 Currency=Currency.Usd />
where SignedLabel - is a Blazor component and Price, Currency is the component's input parameters. I expect Blazor to treat the class word as an html property and apply the plain HTML class to this component so that I can style this component later on. But Blazor actually treats it as another input parameter for component and crashes whole app rendering with error:
Object of type 'SignedLabel' does not have a property matching the name 'class'
So the questions is
Is it possible to use the class property in a such way?
If yes, how should I do this?
PS: project settings:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
</PropertyGroup>
...
</Project >
You cannot apply a class to a Component. You can use splatting to capture attributes placed on a Component to pass as parameter to one of the components elements.
SomeComponent.razor
<div #attributes="#CapturedAttributes">
Hello
</div>
#code {
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string,object> CapturedAttributes { get; set; }
}
##Usage
<SomeComponent id="fred" class="some-css-class" style="width:100vh" />
Will render:
<div id="fred" class="some-css-class" style="width:100vh" >
Hello
</div>
Docs
You just have to create a Parameter in your component. For example, this works fine. In a Tree component, TopDivClass parameter has been added an used.
In the markup of the component:
<div class="#TopDivClass">
In the code behind of the component:
[Parameter]
public string TopDivClass { get; set; }
In the markup using the component:
<Components.Tree TopDivClass="TreeView" />
The result in the HTML is
<div class="TreeView" ...
I've encountered a similar issue and Google led me here, so I share it for anyone who might hit this as well.
My project setup is .NET 7 and Teams App project template (Blazor Server).
The problem was similar to OP's - I wanted to apply CSS class to Web Component. In my case it was FluentTextField, so I couldn't modify its code.
Although doing this:
<FluentTextField
class="w-100"
Placeholder="Provide the URL"
Required="true"/>
wasn't producing any errors and in browser Dev Tools I could see the class added the element, i.e. <fluent-text-field class='w-100'>, the CSS defined in parent component wasn't applied.
Turns out, it's enough to change "Blazor syntax" to "JS syntax" and everything works fine:
<fluent-text-field
class="w-100"
Placeholder="Provide the URL"
Required="true"/>

Polymer paper-card failed to construct CustomElement

I've got an application that seems to work fine when I put all my elements inside a <dom-bind> element. When I remove that dom-bind (no longer needed), most of the elements carry on working, but paper-card stops and throws an error:
"Uncaught DOMException: Failed to construct 'CustomElement': The result must not have attributes"
The error is thrown from polymer/lib/legacy/lib/class.html if that helps. Anyone got any ideas?
I had the same error, and find out angular create an empty element (), then bind stuffs to it.
This fail according to spec:
4.13.2 Requirements for custom element constructors
The element must not gain any attributes or children
https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-conformance
I fix my problem by assigning in connectedCallback()

Nested use of primefaces datalist and fieldset

Is it possible to use primefaces datalist and fieldset elements in a nested way. My application needs to look something like this:
<p:fieldset>
<p:dataList>
<p:fieldset>
<p:datalist>
</p:datalist>
</p:fieldset>
</p:dataList>
</p:fieldset>
I've tried it as mentioned above but I always get the following error:
javax.faces.view.facelets.TagException: /WEB-INF/flows/mainapp/wholesaleInfo.xhtml #106,105 Tag Library supports namespace: http://primefaces.org/ui, but no tag was defined for name: datalist
The datalist mentioned in the error message is of course the inner one... Any ideas how I could make that work? thanks Nikolaus
Try with dataList camelCase instead of datalist, in the inner one. This should make the error go away. However I am unsure if dataLists can be nested. If it's just for layout - display purpose, you may have a look at p:layout

Spring Security multiple filterChainProxy mapping/filters, custom filters Json Output

I have a part of my web application that is an RESTfull api and part a more standard web-pages.
I wish to have the REST part with some custom filters such as the EntryPoint, SuccessHandler and FailureHandler. This part is within the /rest/** mapping.
In the other hand, everything else needs to have more common filters and is mapped with /**.
The problem is to find an easy way to define the filterChainProxy with different mapping-filters.
Right now this solution doesn't work:
<!-- Normal web app -->
<http auto-config="true" use-expressions="true" authentication-manager-ref="authenticationManager">
<form-login/>
<logout/>
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
</http>
<!-- Configure RESTfull services -->
<http use-expressions="true" authentication-manager-ref="authenticationManager" entry-point-ref="restAuthenticationEntryPoint" >
<form-login authentication-success-handler-ref="restAuthenticationSuccessHandler" login-page="/rest/login" username-parameter="username" password-parameter="password" />
<logout logout-url="/rest/logout" />
<intercept-url pattern="/rest/**" method="GET" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/rest/**" method="POST" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/rest/**" method="PUT" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/rest/**" method="DELETE" access="hasRole('ROLE_ADMIN')" />
</http>
It complains with: the univseral match being before other patterns.
Is there a way to define such a thing without resorting to define the filterChainProxy with the definition? The http version does help quite a lot to reduce the amount of configuration as I will have to manually set a UsernamePasswordAuthenticationFilter etc.
The next problem is more simple: I have to respond, after the form-login authentication with a JSON object.
So far, I have implemented a SuccessHandler (actually a version of the SimpleUrlAuthenticationSuccessHandler without the redirect part).
How do I write my JSON output?
I must have something like this:
HTTP 200 OK
with:
{"success":true,"customer {"email":"customer#email.com","session_id":"b83a41dfaca6785399f00837888886e646ff9088"}}
and a similar thing with the FailureHandler. It must be quite simple and it's surely is some very basic thing, but how do you do that? Redirecting to a custom controller is not a solution since I will have the 301 redirect status that a very simple REST client might not be able to understand.
At the very least, I wish to have only the http header and no body at all.
thanks!
If you can upgrade to Spring Security 3.1 it supports multiple chains using namespace configuration.

Anchor tag on ICEfaces component

I'm looking for a way to set focus to an ICEfaces component by means of an anchor tag. For instance, when a field fails validation I want to output something like this:
Field XYZ failed validation
and then, at the XYZ component, have something like:
<ice:inputText id="XYZ" anchor="xyz">
This would enable the user to click on the error message and get focus on the offending component. Is this in any way possible? (I'm aware of the outputLink and inputLink component, but the error message would typically reside in a message.properties file making it hard to use components...)
I'm using ICEfaces version 1.8.2
Use labels. There they are for.
<h:outputLabel for="xyz">message</h:outputLabel>
<h:inputText id="xyz" />
Substitute with ice variants if necessary.