SAAJ insert two prefix in one local part - prefix

I need to insert 2 prefix for one local part. In SAAJ I did
QName bodyName = new QName(url,"local1", "prefix1");
I need another prefix in same body name. It should look like this:
<prefix1:local1 xmlns:prefix1=”url1”
xmlns:prefix2="url2">
Could someone point me to right direction?

The answer is simple:
SOAPBodyElement bodyElement;
bodyElement.addNamespaceDeclaration("prefix2", "url2");

Related

Thymeleaf: Building variable names dynamically

I am trying to build the name of a var dynamically by concatenating the value of a variable and adding some string afterwards, as I add these variable in runtime. Something like the following should work but it does not.
th:text="${__#{myClass.getA().getB()}+'-result'__}"
Is this even possible to do? I dont know the name of the variable, I can only construct it like this unfortunately.
Yes, that is possible, Thymeleaf supports expression preprocessing:
Let's start with some examples:
The message(i18n) expressions should be referenced using the # character. So let's suppose you have the message.key in your translation file. To reference it in Thymeleaf you will have to use
th:text="#{message.key}"
In your scenario your key name is generated dynamically based on a variable so for preprocessing it in thymeleaf you need to use two underscores __
Let's suppose in your context you have a model variable called myModelVariable with a method messagePrefix(). Our example becomes:
th:text="#{__${myModelVariable.messagePrefix()}__}"
This means the myModelVariable.messagePrefix() will be processed first and the result will be used as the key name which will be then resolved to a nice user friendly message.
And if you also want to add a static part at the end of it will look like this:
th:text="#{__${myModelVariable.messagePrefix()}__}+'*'"
Even the key can contain a static part so this is also accepted:
th:text="#{__${myModelVariable.messagePrefix()}__.staticsuffix}+'*'"
More info you can find in the section 2.7 here:
https://www.thymeleaf.org/doc/articles/standarddialect5minutes.html

Using variable on smarty tag name in Shopware

I'm trying to use a variable name to create new snippets, something like this:
{s namespace="frontend/detail/config_variant" name=$variant_group}{/s}
But it doesn't work, it just creates a snippet called $variant_group and I want to get the actual name.
I have tried different combinations and none have worked so far. Can this be generated dynamically?
Thanks
This is already mentioned in the official documentation: https://developers.shopware.com/designers-guide/snippets/#using-dynamic-snippets
{$name = "DetailDataHardness"|cat:$sArticle.attr1}
{$namespace = "frontend/detail/data"}
{$sArticle.attr1|snippet:$name:$namespace}

Codeigniter subfolder named like controller

I'm trying to make folder in controller folder with exact name like controller in Codeigniter. Is it possible by some trick or something?
Screenshot here: http://i.imgur.com/vrQ1J9V.png
If it will be like
/controllers/manage/manage.php
you should add in /config/routes.php
$route['manage/(.*)'] = "manage/manage/$1";
$route['manage'] = "manage/manage";
There is no problem in using the same name, but it is confusing. The best solution would be to change the name, but you can use just fine.
Remember to use the routes with 'manage/manage/function'.
EDIT
I incorrectly viewed the first time and thought manage.php was outside the manage folder.
It will work, but your URL will just have "manage" twice. You could change the routes config to remove the first "manage", but it will be less confusing and time-consuming to just name manage.php something different.

MVC 2 Routing - {Controller}.com/{action}/{id} - Is it Possible?

We have several different domains hosted on an in-house server. They all represent different brands owned by our company and we would like integration between each domain, sharing models, views, resources etc.
What I'd like to do is have {Controller} as the actual domain so it would look like http://{Controller}.com/{Action}/{Id}.
Is this possible? I've seen people do it with sub-domains.
AND, is it worthwhile or is there an easier way to accomplish the same.
If so, does anyone have any suggestions on how I can test this on Localhost?
Yes, it's possible and not all that different to routing based on sub-domains. If you look at this example, he looks at the Host header, splits on the '.' and then takes the first element in the array. You'll simply be taking the second-last element in that array (since "com" is the last element). Basically, in your GetRouteData override, you do something like this:
// Retrieve the url - and split by dots:
var url = httpContext.Request.Headers["HOST"];
var urlParts = url.Split(".");
var routeData = new RouteData(this, new MvcRouteHandler());
routeData.Values.Add("controller", urlParts[urlParts.Count - 2]);
(error-checking and validation not included here, obviously)
As for testing on localhost, you can simply add the domain names you want to test to your hosts file, pointing at 127.0.0.1.

proper way of setting an attribute in Doctrine?

in some tutorials they tell you to set up an attribute like this:
$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
and in the documentation it shows you this:
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(
Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
i wonder which one i should use? isn't it the latter one? cause how can you set an attribute to a singleton class in the first one? isn't the second one more correct?
Do you even understand the code you're looking at?
The first code is "wrong". First it assigns Doctrine_Manager object $managger, and then this variable is not used.
If you want to do more than one thing on Doctrine_Manager then it's natural to get assign this reference to something that won't mess up your code. If you want to do just one thing there is no need to use extra variable, in other words:
Doctrine_Manger::getInstance()->setAttribte(...);
or
$manager = Doctrine_Manger::getInstance();
$manager->setAttribute(...);
$manager->setAttribute(...);
$manager->doSth();
$manager->blahblahblah();

Resources