You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Li, Jonathan" <jo...@sap.com> on 2014/04/14 20:23:27 UTC
Get customized feature parameter value from config.xml
Hi,
In the following sample plugin.xml and config.xml , the parameter "enable-redirect" can be configured by app developers when they add the plugin to cordova project. However, currently only "ios-package" and "onload" parameters are parsed and stored by config.xml's settings parser, other parameters (like "enable-redirect") are ignored by the settings parser, so plugin developer has to parse the config.xml again by themselves in order to get the other parameters' value.
Just wonder it maybe a good idea to parse all parameters under feature element, and return it as a "param" dictionary, so as to make it ready to use by developers within plugin's native code.
Plugin.xml:
<platform name="ios">
<config-file target="config.xml" parent="/widget">
<feature name="myplugin">
<param name="ios-package" value="myPlugin"/>
<param name="onload" value="true"/>
<param name="enable-redirect" value="$REDIRECT"/>
</feature>
</config-file>
<source-file src="ios/libs/myPlugin.a" framework="true"/>
</platform>
Config.xml
<feature name="myplugin">
<param name="ios-package" value="myplugin" />
<param name="onload" value="true" />
<param name="enable-redirect" value="true" />
</feature>
Thanks
Jonathan
Re: Get customized feature parameter value from config.xml
Posted by Shazron <sh...@gmail.com>.
I added the issue: https://issues.apache.org/jira/browse/CB-6458
Re-created below:
For the proposed solution, there are no changes needed to the config.xml
specification, since the feature tag already supports param child tags.
I'm only speaking for iOS, not sure about the other platforms.
The problem is, there is no access to these additional values in plugin
code. The plugin has to re-read the config.xml to access this.
What are the alternatives in config.xml/plugin.xml?
1. preference tag on the plugin level
2. preference tag on the platform level
The problem with either of these two approaches is that if another plugin
has the same key, it will clobber your preference. The ugly solution to
that is, to namespace your key with your feature name as a prefix.
Proposed solutions:
1. Create a plugin in cordova-labs to read these extra param values without
touching the core code.
2. Modify the core code to read these extra param values, and expose them
to the user
On Tue, Apr 15, 2014 at 7:06 PM, Carlos Santana <cs...@gmail.com>wrote:
> Shaz do we have a jira item for this limitation?
>
> Maybe something that can be address short term via plugin dev docs, and
> long term maybe with new config.xml/json :-)
>
>
>
> On Mon, Apr 14, 2014 at 4:29 PM, Li, Jonathan <jo...@sap.com> wrote:
>
> > That works. Thanks.
> >
> > On 4/14/14 4:26 PM, "Shazron" <sh...@gmail.com> wrote:
> >
> > >Yes, that is the known limitation. My suggestion is to prefix the
> > >preference name with your plugin name, or whatever you prefer.
> > >
> > >
> > >On Mon, Apr 14, 2014 at 1:12 PM, Li, Jonathan <jo...@sap.com>
> > wrote:
> > >
> > >> Although the preference can be defined in plugin.xml on per platform
> and
> > >> plugin level, but when the information is used to generate config.xml,
> > >>the
> > >> related preference element will be generated under the root "widget"
> > >> element, and so shared by all plugins. This may cause conflict if the
> > >>same
> > >> preference name is used by multiple plugins.
> > >>
> > >>
> > >>
> > >> On 4/14/14 3:48 PM, "Shazron" <sh...@gmail.com> wrote:
> > >>
> > >> >per platform in the platform tag - yes.
> > >> >plugin level - yes.
> > >> >
> > >> >
> > >> >On Mon, Apr 14, 2014 at 11:34 AM, Li, Jonathan <jo...@sap.com>
> > >> >wrote:
> > >> >
> > >> >> Does "preference" can be set on per platform and plugin level?
> > >> >>
> > >> >> On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
> > >> >>
> > >> >> >Will a <preference /> tag not suffice?
> > >> >> >
> > >> >> >
> > >> >> >On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <
> jonathan.li@sap.com
> > >
> > >> >> >wrote:
> > >> >> >
> > >> >> >> Hi,
> > >> >> >> In the following sample plugin.xml and config.xml , the
> parameter
> > >> >> >> "enable-redirect" can be configured by app developers when they
> > >>add
> > >> >>the
> > >> >> >> plugin to cordova project. However, currently only "ios-package"
> > >>and
> > >> >> >> "onload" parameters are parsed and stored by config.xml's
> settings
> > >> >> >>parser,
> > >> >> >> other parameters (like "enable-redirect") are ignored by the
> > >>settings
> > >> >> >> parser, so plugin developer has to parse the config.xml again by
> > >> >> >>themselves
> > >> >> >> in order to get the other parameters' value.
> > >> >> >>
> > >> >> >> Just wonder it maybe a good idea to parse all parameters under
> > >> >>feature
> > >> >> >> element, and return it as a "param" dictionary, so as to make it
> > >> >>ready
> > >> >> >>to
> > >> >> >> use by developers within plugin's native code.
> > >> >> >>
> > >> >> >> Plugin.xml:
> > >> >> >> <platform name="ios">
> > >> >> >> <config-file target="config.xml" parent="/widget">
> > >> >> >> <feature name="myplugin">
> > >> >> >> <param name="ios-package" value="myPlugin"/>
> > >> >> >> <param name="onload" value="true"/>
> > >> >> >> <param name="enable-redirect" value="$REDIRECT"/>
> > >> >> >> </feature>
> > >> >> >> </config-file>
> > >> >> >> <source-file src="ios/libs/myPlugin.a"
> framework="true"/>
> > >> >> >> </platform>
> > >> >> >>
> > >> >> >> Config.xml
> > >> >> >> <feature name="myplugin">
> > >> >> >> <param name="ios-package" value="myplugin" />
> > >> >> >> <param name="onload" value="true" />
> > >> >> >> <param name="enable-redirect" value="true" />
> > >> >> >> </feature>
> > >> >> >>
> > >> >> >> Thanks
> > >> >> >> Jonathan
> > >> >> >>
> > >> >>
> > >> >>
> > >>
> > >>
> >
> >
>
>
> --
> Carlos Santana
> <cs...@gmail.com>
>
Re: Get customized feature parameter value from config.xml
Posted by Carlos Santana <cs...@gmail.com>.
Shaz do we have a jira item for this limitation?
Maybe something that can be address short term via plugin dev docs, and
long term maybe with new config.xml/json :-)
On Mon, Apr 14, 2014 at 4:29 PM, Li, Jonathan <jo...@sap.com> wrote:
> That works. Thanks.
>
> On 4/14/14 4:26 PM, "Shazron" <sh...@gmail.com> wrote:
>
> >Yes, that is the known limitation. My suggestion is to prefix the
> >preference name with your plugin name, or whatever you prefer.
> >
> >
> >On Mon, Apr 14, 2014 at 1:12 PM, Li, Jonathan <jo...@sap.com>
> wrote:
> >
> >> Although the preference can be defined in plugin.xml on per platform and
> >> plugin level, but when the information is used to generate config.xml,
> >>the
> >> related preference element will be generated under the root "widget"
> >> element, and so shared by all plugins. This may cause conflict if the
> >>same
> >> preference name is used by multiple plugins.
> >>
> >>
> >>
> >> On 4/14/14 3:48 PM, "Shazron" <sh...@gmail.com> wrote:
> >>
> >> >per platform in the platform tag - yes.
> >> >plugin level - yes.
> >> >
> >> >
> >> >On Mon, Apr 14, 2014 at 11:34 AM, Li, Jonathan <jo...@sap.com>
> >> >wrote:
> >> >
> >> >> Does "preference" can be set on per platform and plugin level?
> >> >>
> >> >> On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
> >> >>
> >> >> >Will a <preference /> tag not suffice?
> >> >> >
> >> >> >
> >> >> >On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jonathan.li@sap.com
> >
> >> >> >wrote:
> >> >> >
> >> >> >> Hi,
> >> >> >> In the following sample plugin.xml and config.xml , the parameter
> >> >> >> "enable-redirect" can be configured by app developers when they
> >>add
> >> >>the
> >> >> >> plugin to cordova project. However, currently only "ios-package"
> >>and
> >> >> >> "onload" parameters are parsed and stored by config.xml's settings
> >> >> >>parser,
> >> >> >> other parameters (like "enable-redirect") are ignored by the
> >>settings
> >> >> >> parser, so plugin developer has to parse the config.xml again by
> >> >> >>themselves
> >> >> >> in order to get the other parameters' value.
> >> >> >>
> >> >> >> Just wonder it maybe a good idea to parse all parameters under
> >> >>feature
> >> >> >> element, and return it as a "param" dictionary, so as to make it
> >> >>ready
> >> >> >>to
> >> >> >> use by developers within plugin's native code.
> >> >> >>
> >> >> >> Plugin.xml:
> >> >> >> <platform name="ios">
> >> >> >> <config-file target="config.xml" parent="/widget">
> >> >> >> <feature name="myplugin">
> >> >> >> <param name="ios-package" value="myPlugin"/>
> >> >> >> <param name="onload" value="true"/>
> >> >> >> <param name="enable-redirect" value="$REDIRECT"/>
> >> >> >> </feature>
> >> >> >> </config-file>
> >> >> >> <source-file src="ios/libs/myPlugin.a" framework="true"/>
> >> >> >> </platform>
> >> >> >>
> >> >> >> Config.xml
> >> >> >> <feature name="myplugin">
> >> >> >> <param name="ios-package" value="myplugin" />
> >> >> >> <param name="onload" value="true" />
> >> >> >> <param name="enable-redirect" value="true" />
> >> >> >> </feature>
> >> >> >>
> >> >> >> Thanks
> >> >> >> Jonathan
> >> >> >>
> >> >>
> >> >>
> >>
> >>
>
>
--
Carlos Santana
<cs...@gmail.com>
Re: Get customized feature parameter value from config.xml
Posted by "Li, Jonathan" <jo...@sap.com>.
That works. Thanks.
On 4/14/14 4:26 PM, "Shazron" <sh...@gmail.com> wrote:
>Yes, that is the known limitation. My suggestion is to prefix the
>preference name with your plugin name, or whatever you prefer.
>
>
>On Mon, Apr 14, 2014 at 1:12 PM, Li, Jonathan <jo...@sap.com> wrote:
>
>> Although the preference can be defined in plugin.xml on per platform and
>> plugin level, but when the information is used to generate config.xml,
>>the
>> related preference element will be generated under the root "widget"
>> element, and so shared by all plugins. This may cause conflict if the
>>same
>> preference name is used by multiple plugins.
>>
>>
>>
>> On 4/14/14 3:48 PM, "Shazron" <sh...@gmail.com> wrote:
>>
>> >per platform in the platform tag - yes.
>> >plugin level - yes.
>> >
>> >
>> >On Mon, Apr 14, 2014 at 11:34 AM, Li, Jonathan <jo...@sap.com>
>> >wrote:
>> >
>> >> Does "preference" can be set on per platform and plugin level?
>> >>
>> >> On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
>> >>
>> >> >Will a <preference /> tag not suffice?
>> >> >
>> >> >
>> >> >On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jo...@sap.com>
>> >> >wrote:
>> >> >
>> >> >> Hi,
>> >> >> In the following sample plugin.xml and config.xml , the parameter
>> >> >> "enable-redirect" can be configured by app developers when they
>>add
>> >>the
>> >> >> plugin to cordova project. However, currently only "ios-package"
>>and
>> >> >> "onload" parameters are parsed and stored by config.xml's settings
>> >> >>parser,
>> >> >> other parameters (like "enable-redirect") are ignored by the
>>settings
>> >> >> parser, so plugin developer has to parse the config.xml again by
>> >> >>themselves
>> >> >> in order to get the other parameters' value.
>> >> >>
>> >> >> Just wonder it maybe a good idea to parse all parameters under
>> >>feature
>> >> >> element, and return it as a "param" dictionary, so as to make it
>> >>ready
>> >> >>to
>> >> >> use by developers within plugin's native code.
>> >> >>
>> >> >> Plugin.xml:
>> >> >> <platform name="ios">
>> >> >> <config-file target="config.xml" parent="/widget">
>> >> >> <feature name="myplugin">
>> >> >> <param name="ios-package" value="myPlugin"/>
>> >> >> <param name="onload" value="true"/>
>> >> >> <param name="enable-redirect" value="$REDIRECT"/>
>> >> >> </feature>
>> >> >> </config-file>
>> >> >> <source-file src="ios/libs/myPlugin.a" framework="true"/>
>> >> >> </platform>
>> >> >>
>> >> >> Config.xml
>> >> >> <feature name="myplugin">
>> >> >> <param name="ios-package" value="myplugin" />
>> >> >> <param name="onload" value="true" />
>> >> >> <param name="enable-redirect" value="true" />
>> >> >> </feature>
>> >> >>
>> >> >> Thanks
>> >> >> Jonathan
>> >> >>
>> >>
>> >>
>>
>>
Re: Get customized feature parameter value from config.xml
Posted by Shazron <sh...@gmail.com>.
Yes, that is the known limitation. My suggestion is to prefix the
preference name with your plugin name, or whatever you prefer.
On Mon, Apr 14, 2014 at 1:12 PM, Li, Jonathan <jo...@sap.com> wrote:
> Although the preference can be defined in plugin.xml on per platform and
> plugin level, but when the information is used to generate config.xml, the
> related preference element will be generated under the root "widget"
> element, and so shared by all plugins. This may cause conflict if the same
> preference name is used by multiple plugins.
>
>
>
> On 4/14/14 3:48 PM, "Shazron" <sh...@gmail.com> wrote:
>
> >per platform in the platform tag - yes.
> >plugin level - yes.
> >
> >
> >On Mon, Apr 14, 2014 at 11:34 AM, Li, Jonathan <jo...@sap.com>
> >wrote:
> >
> >> Does "preference" can be set on per platform and plugin level?
> >>
> >> On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
> >>
> >> >Will a <preference /> tag not suffice?
> >> >
> >> >
> >> >On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jo...@sap.com>
> >> >wrote:
> >> >
> >> >> Hi,
> >> >> In the following sample plugin.xml and config.xml , the parameter
> >> >> "enable-redirect" can be configured by app developers when they add
> >>the
> >> >> plugin to cordova project. However, currently only "ios-package" and
> >> >> "onload" parameters are parsed and stored by config.xml's settings
> >> >>parser,
> >> >> other parameters (like "enable-redirect") are ignored by the settings
> >> >> parser, so plugin developer has to parse the config.xml again by
> >> >>themselves
> >> >> in order to get the other parameters' value.
> >> >>
> >> >> Just wonder it maybe a good idea to parse all parameters under
> >>feature
> >> >> element, and return it as a "param" dictionary, so as to make it
> >>ready
> >> >>to
> >> >> use by developers within plugin's native code.
> >> >>
> >> >> Plugin.xml:
> >> >> <platform name="ios">
> >> >> <config-file target="config.xml" parent="/widget">
> >> >> <feature name="myplugin">
> >> >> <param name="ios-package" value="myPlugin"/>
> >> >> <param name="onload" value="true"/>
> >> >> <param name="enable-redirect" value="$REDIRECT"/>
> >> >> </feature>
> >> >> </config-file>
> >> >> <source-file src="ios/libs/myPlugin.a" framework="true"/>
> >> >> </platform>
> >> >>
> >> >> Config.xml
> >> >> <feature name="myplugin">
> >> >> <param name="ios-package" value="myplugin" />
> >> >> <param name="onload" value="true" />
> >> >> <param name="enable-redirect" value="true" />
> >> >> </feature>
> >> >>
> >> >> Thanks
> >> >> Jonathan
> >> >>
> >>
> >>
>
>
Re: Get customized feature parameter value from config.xml
Posted by "Li, Jonathan" <jo...@sap.com>.
Although the preference can be defined in plugin.xml on per platform and
plugin level, but when the information is used to generate config.xml, the
related preference element will be generated under the root "widget"
element, and so shared by all plugins. This may cause conflict if the same
preference name is used by multiple plugins.
On 4/14/14 3:48 PM, "Shazron" <sh...@gmail.com> wrote:
>per platform in the platform tag - yes.
>plugin level - yes.
>
>
>On Mon, Apr 14, 2014 at 11:34 AM, Li, Jonathan <jo...@sap.com>
>wrote:
>
>> Does "preference" can be set on per platform and plugin level?
>>
>> On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
>>
>> >Will a <preference /> tag not suffice?
>> >
>> >
>> >On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jo...@sap.com>
>> >wrote:
>> >
>> >> Hi,
>> >> In the following sample plugin.xml and config.xml , the parameter
>> >> "enable-redirect" can be configured by app developers when they add
>>the
>> >> plugin to cordova project. However, currently only "ios-package" and
>> >> "onload" parameters are parsed and stored by config.xml's settings
>> >>parser,
>> >> other parameters (like "enable-redirect") are ignored by the settings
>> >> parser, so plugin developer has to parse the config.xml again by
>> >>themselves
>> >> in order to get the other parameters' value.
>> >>
>> >> Just wonder it maybe a good idea to parse all parameters under
>>feature
>> >> element, and return it as a "param" dictionary, so as to make it
>>ready
>> >>to
>> >> use by developers within plugin's native code.
>> >>
>> >> Plugin.xml:
>> >> <platform name="ios">
>> >> <config-file target="config.xml" parent="/widget">
>> >> <feature name="myplugin">
>> >> <param name="ios-package" value="myPlugin"/>
>> >> <param name="onload" value="true"/>
>> >> <param name="enable-redirect" value="$REDIRECT"/>
>> >> </feature>
>> >> </config-file>
>> >> <source-file src="ios/libs/myPlugin.a" framework="true"/>
>> >> </platform>
>> >>
>> >> Config.xml
>> >> <feature name="myplugin">
>> >> <param name="ios-package" value="myplugin" />
>> >> <param name="onload" value="true" />
>> >> <param name="enable-redirect" value="true" />
>> >> </feature>
>> >>
>> >> Thanks
>> >> Jonathan
>> >>
>>
>>
Re: Get customized feature parameter value from config.xml
Posted by Shazron <sh...@gmail.com>.
per platform in the platform tag - yes.
plugin level - yes.
On Mon, Apr 14, 2014 at 11:34 AM, Li, Jonathan <jo...@sap.com> wrote:
> Does "preference" can be set on per platform and plugin level?
>
> On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
>
> >Will a <preference /> tag not suffice?
> >
> >
> >On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jo...@sap.com>
> >wrote:
> >
> >> Hi,
> >> In the following sample plugin.xml and config.xml , the parameter
> >> "enable-redirect" can be configured by app developers when they add the
> >> plugin to cordova project. However, currently only "ios-package" and
> >> "onload" parameters are parsed and stored by config.xml's settings
> >>parser,
> >> other parameters (like "enable-redirect") are ignored by the settings
> >> parser, so plugin developer has to parse the config.xml again by
> >>themselves
> >> in order to get the other parameters' value.
> >>
> >> Just wonder it maybe a good idea to parse all parameters under feature
> >> element, and return it as a "param" dictionary, so as to make it ready
> >>to
> >> use by developers within plugin's native code.
> >>
> >> Plugin.xml:
> >> <platform name="ios">
> >> <config-file target="config.xml" parent="/widget">
> >> <feature name="myplugin">
> >> <param name="ios-package" value="myPlugin"/>
> >> <param name="onload" value="true"/>
> >> <param name="enable-redirect" value="$REDIRECT"/>
> >> </feature>
> >> </config-file>
> >> <source-file src="ios/libs/myPlugin.a" framework="true"/>
> >> </platform>
> >>
> >> Config.xml
> >> <feature name="myplugin">
> >> <param name="ios-package" value="myplugin" />
> >> <param name="onload" value="true" />
> >> <param name="enable-redirect" value="true" />
> >> </feature>
> >>
> >> Thanks
> >> Jonathan
> >>
>
>
Re: Get customized feature parameter value from config.xml
Posted by "Li, Jonathan" <jo...@sap.com>.
Does "preference" can be set on per platform and plugin level?
On 4/14/14 2:27 PM, "Shazron" <sh...@gmail.com> wrote:
>Will a <preference /> tag not suffice?
>
>
>On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jo...@sap.com>
>wrote:
>
>> Hi,
>> In the following sample plugin.xml and config.xml , the parameter
>> "enable-redirect" can be configured by app developers when they add the
>> plugin to cordova project. However, currently only "ios-package" and
>> "onload" parameters are parsed and stored by config.xml's settings
>>parser,
>> other parameters (like "enable-redirect") are ignored by the settings
>> parser, so plugin developer has to parse the config.xml again by
>>themselves
>> in order to get the other parameters' value.
>>
>> Just wonder it maybe a good idea to parse all parameters under feature
>> element, and return it as a "param" dictionary, so as to make it ready
>>to
>> use by developers within plugin's native code.
>>
>> Plugin.xml:
>> <platform name="ios">
>> <config-file target="config.xml" parent="/widget">
>> <feature name="myplugin">
>> <param name="ios-package" value="myPlugin"/>
>> <param name="onload" value="true"/>
>> <param name="enable-redirect" value="$REDIRECT"/>
>> </feature>
>> </config-file>
>> <source-file src="ios/libs/myPlugin.a" framework="true"/>
>> </platform>
>>
>> Config.xml
>> <feature name="myplugin">
>> <param name="ios-package" value="myplugin" />
>> <param name="onload" value="true" />
>> <param name="enable-redirect" value="true" />
>> </feature>
>>
>> Thanks
>> Jonathan
>>
Re: Get customized feature parameter value from config.xml
Posted by Shazron <sh...@gmail.com>.
Will a <preference /> tag not suffice?
On Mon, Apr 14, 2014 at 11:23 AM, Li, Jonathan <jo...@sap.com> wrote:
> Hi,
> In the following sample plugin.xml and config.xml , the parameter
> "enable-redirect" can be configured by app developers when they add the
> plugin to cordova project. However, currently only "ios-package" and
> "onload" parameters are parsed and stored by config.xml's settings parser,
> other parameters (like "enable-redirect") are ignored by the settings
> parser, so plugin developer has to parse the config.xml again by themselves
> in order to get the other parameters' value.
>
> Just wonder it maybe a good idea to parse all parameters under feature
> element, and return it as a "param" dictionary, so as to make it ready to
> use by developers within plugin's native code.
>
> Plugin.xml:
> <platform name="ios">
> <config-file target="config.xml" parent="/widget">
> <feature name="myplugin">
> <param name="ios-package" value="myPlugin"/>
> <param name="onload" value="true"/>
> <param name="enable-redirect" value="$REDIRECT"/>
> </feature>
> </config-file>
> <source-file src="ios/libs/myPlugin.a" framework="true"/>
> </platform>
>
> Config.xml
> <feature name="myplugin">
> <param name="ios-package" value="myplugin" />
> <param name="onload" value="true" />
> <param name="enable-redirect" value="true" />
> </feature>
>
> Thanks
> Jonathan
>