What is the equivalent of newSessionStore in wicket 1.5.7? - wicket-1.5

newSessionStore() method is removed from wicket 1.5.
#Override
protected ISessionStore newSessionStore()
{
return new HttpSessionStore(this);
}
what is the equivalent of this method in 1.5?

According to migration guide there's no equivalent in Wicket 1.5. Only HttpSessionStore is supported

Related

Is there an alternative for setMaxRetryTimeoutMillis method

I am using setMaxRetryTimeoutMillis(10000) method in my project but in latest org.elasticsearch.client this method has been removed. So would like to know whether there is any alternate method which can be used for it or any alternate way to implement the same functionality.
Here is the current code:
#Bean
public RestHighLevelClient restHighLevelClient(){
return new RestHighLevelClient(RestClient.builder(new HttpHost("xyz",9000,"")).setMaxRetryTimeoutMillis(10000));
}

SpringBoot log4j AppenderSkeleton The method append(LoggingEvent) must override or implement a supertype method

I'm trying to create a custom appender using log4j after looking at the given example -
Link:- How to create my own Appender in log4j?
I did as follows:-
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
public class MyCustomAppender extends AppenderSkeleton
{
private MailServiceImpl mail = new MailServiceImpl();
#Override
public void close() {
}
#Override
public boolean requiresLayout() {
return false;
}
#Override
protected void append(LoggingEvent event) {
mail.sendMail(event.toString());
}
}
It gives me error because of the overridden methods - The method append(LoggingEvent) of type MyCustomAppender must override or implement a supertype method. I tried to search for solution but found none. And nobody seem to have faced the problem. Where am I going wrong? Please help me.
I believe you are looking for a solution for Log4j2 but the stackoverflow page you are linking to is over 3 years old ( might be an older version of Log4j )
Looking at javadoc of older version it does show AppenderSkeleton could be used to override the appender() method however you mention you get a compile error
The method append(LoggingEvent) of type MyCustomAppender must override
or implement a supertype method
This is because there is no such method to override in Log4j2
Please provide version of what Log4j you are using, meanwhile have a look at this answer incase you are using Log4j2

Spring "SchedulerFactoryBean" overrides the "jobstore" properties value

If you are using Spring's SchedulerFactoryBean, it overrides the configured value from the properties file.
So if you tried to use JobStoreTx it is always overridden by the LocalDataSourceJobStore from spring
Code snippet below shows the part from the SchedulerFactoryBean. I have overcome it by using a customizer.
if (this.dataSource != null) {
mergedProps.setProperty(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
}
Using #QuartzDataSource should handle the problem as #nonzaprej mentioned in the comments
Here is also how I have overridden the value using a customizer
#Component
public class SchedulerFactoryCustomizer implements SchedulerFactoryBeanCustomizer {
using the customize method
#Override
public void customize(SchedulerFactoryBean schedulerFactoryBean) {
schedulerFactoryBean.setDataSource(dataSource);
}

Is there a Spring Security 4.x taglib for Facelets

I'm involved working in a project using Spring Security 4.x and JSF 2.2 with Facelets. I just noticed that spring security in this version have enabled by default the protection against Cross Site Request Forgery using request tokens, the case is that you have to put the tag <sec:csrfMetaTags> in many pages (if not, spring deny the request), the lib spring-faces is in 2.4.1 which hasn't these tags for Facelets (XHTML).
I tried to find an implementation in order to get working my project using these frameworks but I couldn't find any, do you know any adaptation?
In my case, I adapted just the part I needed (at this point), if there are no public adaptations, I'd be glad to put it into an open source project and try to adapt all the library.
Thanks.
UPDATE
I created a blog post explaining my solution:
http://halexv.blogspot.mx/2015/07/spring-security-4x-csrf-protection-for.html
You have the spring taglib for the JSF which you can access from this link.
http://docs.spring.io/spring-webflow/docs/current/reference/html/spring-faces.html#spring-faces-security-taglib
I believe you already know this. But your actual question is related to the CRSF which you have to add to all your pages. This in specific can be achieved by adding the token automatically to your forms as below
Create a util class and add a token generator
static String getTokenForSession (HttpSession session) {
String token = null;
synchronized (session) {
token = (String) session.getAttribute(CSRF_TOKEN_FOR_SESSION_ATTR_NAME);
if (null==token) {
token=UUID.randomUUID().toString();
session.setAttribute(CSRF_TOKEN_FOR_SESSION_ATTR_NAME, token);
}
}
return token;
}
implement RequestDataValueProcessor
public class CSRFRequestDataValueProcessor implements RequestDataValueProcessor {
...
#Override
public Map<String,String> getExtraHiddenFields(HttpServletRequest request) {
Map<String,String> hiddenFields = new HashMap<String,String>();
hiddenFields.put(CSRFTokenManager.CSRF_PARAM_NAME, CSRFTokenManager.getTokenForSession(request.getSession()));
return hiddenFields;
}
}
Then define the bean
<bean name="requestDataValueProcessor" class="com...CSRFRequestDataValueProcessor"/>
Creadit Reference - http://blog.eyallupu.com/2012/04/csrf-defense-in-spring-mvc-31.html

Wicket Decorator to Listener when upgrade from 1.5.x to 6.x

I have been requested to upgrade the wicket version from 1.5.9 to 6.14.0 in a web-app.
I have found upgrading the (behavior) decorators to listeners very problematic.
https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax#WicketAjax-o.a.w.ajax.IAjaxCallDecoratorisreplacedwitho.a.w.ajax.attributes.IAjaxCallListener
o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener.
I have succeeded in creating a POC where I upgrade the needed parts almost correctly.
In 1.5.9 the element script can be decorated like this (at low level, there is also other changes involved, but it ends to this)
public class MyBehavior extends AjaxFormComponentUpdatingBehavior {
#Override
// (removed in upgrade to 6.14.0)
protected IAjaxCallDecorator getAjaxCallDecorator() {
return new SmallDecorator();
}
private class SmallDecorator extends AjaxCallDecorator {
public SmallDecorator() {}
#Override
public CharSequence decorateScript(Component component, CharSequence script) {
return "alert('decorated onblur');" + script;
}
}
}
In 6.14.0 the same is done like this (as far as I have understood it correctly)
public class OnBlurBehavior extends AjaxFormComponentUpdatingBehavior {
#Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new
GenericListenerImpl("alert('Listener onblur')"));
}
private class GenericListenerImpl extends AjaxCallListener {
private String decoratorScript = null;
public GenericListenerImpl(String decoratorScript) {
this.decoratorScript = decoratorScript;
}
#Override
public CharSequence getPrecondition(Component component) {
return this.decoratorScript;
}
}
}
Now this works in basic, but when I want to edit or wrap the "script" like in the 1.5.9 version is done, how can I accomplish that in the 6.14.0 version?
This has proved to me extremely problematic as I haven't used Wicket for a (very) long time and kind of being a noob is specially what comes to the latest version. :)
I was in impression that the "script" part in 1.5.9 contains a single String of element attributes (or something like that) UI developer had added for the element in html. But checking that in detail reveals that the "script" content actually looks something like this:
var wcall=wicketAjaxPost('./?0-1.IBehaviorListener.0-input', wicketSerialize(Wicket.$('input')),function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('input') != null;}.bind(this));
So the "script" is something generated by the wicket and actually there is no content that could had been set by the (UI) developer and could require modification on the java side.
In general I consider such behavior bad (as in 1.5.9) when given the generated script to be modified and omitting this option alltogether in upgrade to 6.14.0 seems justified... Even that this causes gray hair and extra work to fix the functionality getting broken with the upgrade.
The code examples given above are correct, you just need to figure out what behavior to add (override) in GenericListenerImpl to gain the same functionality as with decorating the script with SmallDecorator.
The API for AjaxCallDecorator appears to be bad as it does not explaing the parameters with the 'decorateScript', thus I was mislead with the issue...
http://wicket.apache.org/apidocs/1.5/org/apache/wicket/ajax/calldecorator/AjaxCallDecorator.html#decorateScript%28org.apache.wicket.Component,%20java.lang.CharSequence%29

Resources