• Welcome to KonaKart Community Forum. Please login or sign up.
 

kkAppEng.getEng() returns new KKEngIf?

Started by unic1988, February 11, 2009, 07:34:54 am

Previous topic - Next topic

unic1988

Hello,

For some reasons I need to know the IP Address of the Customer in the KKCustomEng. I couldn't find any method that gives me the IP Address so I thought it would be best to set it from an Action (BaseAction.java).

It seems that getKKAppEng(HttpServletRequest) is the method that gets called nearly everytime an Action is performed, so I customized it a bit to have access to the IP Address from KKCustomEng.

1. I made a new dataelement in KKCustomEng named "String remoteAddr"
2. I modified BaseAction.getKKAppEng() this way:

...
        kkAppEng.setPageTitle(getCatMessage(request, "seo.default.title"));
        kkAppEng.setMetaDescription(getCatMessage(request, "seo.default.meta.description"));
        kkAppEng.setMetaKeywords(getCatMessage(request, "seo.default.meta.keywords"));

/* CUSTOMIZATION */

try {

String ip = request.getRemoteAddr();

if(kkAppEng.getEng() instanceof KKCustomEng && ip != null) {

((KKCustomEng)kkAppEng.getEng()).setRemoteAddr(ip);
}
}
catch(Exception e) {

mylog.debug("Error " + e.getMessage());
}

/* CUSTOMIZATION */

        return kkAppEng;
    }


First it seemed to work, but I never had the IP Adress available in KKCustomEng. Does kkAppEng.getEng() always return a new KKEngIf-object?

If yes: Is there another Way to pass the Ip Address to KKCustomEng?

Thanks in advance

julie

QuoteDoes kkAppEng.getEng() always return a new KKEngIf-object?


No it doesn't. It creates an instance at start up and always returns that instance.