titanuum mobile xmlmarkup events - templates

moving from actionscript (flex) to titanium and I'm experimenting with the xml markup. What I have is a template that I picked up from the doc
<ItemTemplate name="template">
<ImageView left="0" bindId="pic" id="icon" />
<Label bindId="info" id="title"/>
</ItemTemplate>
</Templates>
my question is if someone clicks on the pic or a listitem itself, how does one handle the events. through xml markup? Then how do you reference any of the control wrap in the template?
I have tried
<ImageView left="0" bindId="pic" id="icon" onclick="doClick()" />
function doClick(e) {
alert($.info.text);
}
This just produces a error and I still would not know what pic was clicked.
any help would be great..
thanks Mike

Have you checked out the Alloy Quick Start? I think many of your questions can be answered there.
Anyway, for ListViews, you cant add an event listener to an item in the template, its just a template not an actual thing on the screen (yet), refer here, and look at the alloy section.
Instead you need the itemclick event listener on the ListView itself. Check , below for a simple example of what the XML markup looks like.
<ListView id="listView" defaultItemTemplate="template" onitemclick="yourEvent" >
<!-- The Templates tag sets the ListView's templates property -->
<Templates>
<!-- Define your item templates within the Templates tags or use the
Require tag to include a view that only contains an ItemTemplate -->
<ItemTemplate name="template">
<ImageView bindId="pic" id="icon" />
<Label bindId="info" id="title" />
<Label bindId="es_info" id="subtitle" />
</ItemTemplate>
</Templates>
<ListSection headerTitle="Fruit / Frutas">
<!-- You can specify any ListItem or ListDataItem properties in ListItem -->
<!-- Specify data to bind to the item template with inline attributes
defined as <bindId>:<Ti.UI.Component.property> -->
<ListItem info:text="Apple" es_info:text="Manzana" pic:image="/apple.png" />
<ListItem info:text="Banana" es_info:text="Banana" pic:image="/banana.png" />
</ListSection>
</ListView>
Also, you need any JavaScript to be in the controller files, not in the XML markup files. *.js has javascript that is behind the view, which is *.xml.

Related

What are "as" props in semantic-ui-react components?

as is defined as An element type to render as (string or function). in the most of the components in semantic-UI-react. What does that mean?
My understanding is that it somehow changes the component in whatever is as is.
Example:
https://react.semantic-ui.com/modules/sidebar
has Sidebar as={Menu} then the children are <Menu.Item name='...'> without typical <Menu/> that is required to start the menu.
This feature is called augmentation, you can control the rendered HTML tag or render one component as another component. Extra props are passed to the component you are rendering as. It allows to compose component features and props without adding extra nested components.
Your example with Sidebar shows that Sidebar will render its children to Menu. This can also be written in the following way, but this procudes extra markup, which is not always correct and possibly can break styling.
<Sidebar>
<Menu>
<Menu.Item />
</Menu>
</Sidebar>
Basic example with tags:
<Button /> // will produce <button class='ui button' />
<Button as='a' /> // will produce <a class='ui button' />
Example with react-router:
<Menu.Item as={Link} to='/home' /> // will produce <a class="item" href="/home">

Joomla Template Paramenter Type Menu Assignment

I use Joomla 3.2.1.
I create a new template and add some configuration parameter.
Now I need in my advanced configuration a selection, where I can set the menu assignment for a slideshow in my template. The Slideshow is html / javascript (jquery). I can enable/disable it in configuration.
But I want to assign it to menu item. Is there a configuration parameter type for this? I couldnt find.
my configuration looks like:
<config>
<fields name="params" >
<fieldset name="advanced">
<field type="spacer" label="Slideshow" />
<field name="isSlideshow" type="radio"
class="btn-group btn-group-yesno"
default="1"
label="Slideshow">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<!-- add menu assingment-->
<field type="menut assignment???"....>
<field name="slide1" type="media" default=""
label="Slide 1"/>
<field name="slide2" type="media" default=""
label="Slide 2"/>
<field name="slide3" type="media" default=""
label="Slide 3"/>
</fieldset>
</fields>
</config>
You should create a module with the slideshow code.
Then assign the module to a position in your template, where you will include the position:
<jdoc:include type="modules" name="slideshow" />
Install the module in the slideshow position, then in the module settings, tab "Menu Assignment", choose "Only on the pages selected";
below you can tick the menu items you want it to show on.
There are a few cases where this is not sufficient, i.e. in the blog view the articles will share the same menu item, but you might want to treat them differently. You have many options here, the best is to create a different - named position in the template, and assign the modules to the appropriate one, i.e.:
<jdoc:include type="modules" name="slideshow-all" />
<jdoc:include type="modules" name="slideshow-articles" />

jsf header navigation menu - template

I have template like here:
http://www.mkyong.com/jsf2/jsf-2-templating-with-facelets-example/
i add menu navigation:
<h:form id="form">
<div id="page">
<div id="header">
<ui:insert name="header" >
<ui:include src="/pages/template/header.xhtml" />
</ui:insert>
<f:ajax render="ContentLoader">
<h:commandLink actionListener="#{contentPage.setPage('/pages/first.xhtml')}" value="About Us" />
<h:commandLink actionListener="#{contentPage.setPage('/pages/login.xhtml')}" value="Contact Us" />
</f:ajax>
</div>
<h:panelGroup id="ContentLoader" >
<div id="content">
<ui:insert name="content" >
<ui:include src="#{contentPage.page}" />
</ui:insert>
</div>
</h:panelGroup>
</div>
</h:form>
links are working fine, but i have problem with redirect content by useing <h:commandButton action="link"> which is in content
how can i fix this problem?
maybe it's something wrong with my layout?
or how to correctly redirect from content to another content, useing buttons which are in contents?
As to your concrete problem, it's likely caused by the combination <ui:include src="#{...}"> and a view scoped bean. This construct works only if you upgrade to at least Mojarra 2.1.18. Otherwise, the view scoped bean will fail to restore and be newly recreated and therefore the default value of #{contentPage.page} will be considered when any form actions inside the page are to be decoded. Upgrading to at least Mojarra 2.1.18 should fix your problem. You can get it at http://javaserverfaces.java.net. It's currently already at 2.1.25.
As to your concrete functional requirement, using command links/buttons for plain page-to-page navigation is a poor practice. You should be using output links/buttons for this.
<h:button value="navigate" outcome="link" />
or
<h:link value="navigate" outcome="link" />

Field not displaying on list with Content types Inherits="False"

I've defined a content type 'related links' and set Inherits="False" and added line to remove out-of-the-box 'title' field as I don't want it showing in the view or new/edit/display forms, see (OPTION 1) in CAML below.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- ===== Fields ===== -->
<!-- Link Category -->
<Field DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Group="Custom"
Overwrite="True"
Type="Lookup"
ShowField="Title"
List="Lists/LinkCategoryList"
WebId="~sitecollection" />
<!-- ===== Content Type ===== -->
<!--
Related Links
- Parent ContentType: Item (0x01)
-->
<ContentType Name="Related Links"
ID="0x0100c11a1db14e564574bc49a2aa9bf325d3"
Group="Custom"
Description=""
Inherits="False"
Version="0">
<FieldRefs>
<!-- Title (OPTION 1) -->
<RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />
<!-- (OPTION 2)
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Hidden="TRUE" Required="FALSE" DisplayName="_hidden" />
-->
<!-- Link Category -->
<FieldRef DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Required="True" />
</FieldRefs>
</ContentType>
</Elements>
This does remove the 'title' field from the content type but when I try to associate the content type with a list it does not display the 'LinkCategory' field in the view or new/edit/display forms. Why is it so?
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint"
Title="Related Links"
FolderCreation="FALSE"
Direction="$Resources:Direction;"
Url="Lists/RelatedLinksListDefinition"
BaseType="0"
EnableContentTypes="True"
xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<!-- Related Links -->
<ContentTypeRef ID="0x0100c11a1db14e564574bc49a2aa9bf325d3" />
</ContentTypes>
<Fields>
</Fields>
<Views>
<View ...etc...>
<ViewFields>
<FieldRef Name="LinkCategory"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
As a work around I've set Inherits="True" on the content type and used (OPTION 2) in content type CAML and that hides the 'title' field, but would really like to understand what's going on here and what's the best approach to take. Thanks in advance!
PS: This post has similar question: SharePoint 2010: RemoveFieldRef and Inherits="TRUE"
PSS: When I browse via SP Manager 2010 after deploying using OPTION 1, I get the following:
'Link Category' Field created correctly
'Related Links' Content Type created correctly with 'Link Category' field
'Related Links' list created with 'Related Links' Content Type associated
However 'Related Links' list has no reference to 'Link Category' Field.
Ok so was on my way up the garden path...
The issue why 'Link Category' Field was not being created on the 'Related Links' list wasn't related to setting Inherits="False", it was because I had not defined it in the list schema even though I'd defined it in the content type. As mentioned here:
http://msdn.microsoft.com/en-us/library/aa543576.aspx
When SharePoint Foundation creates a list instance, it includes only
those columns that are declared in the base type schema of the list or
in the list schema. If you reference a site content type in the list
schema, and that content type references site columns that are not
included in the base type schema of the list or in the list schema,
those columns are not included. You must declare those columns in the
list schema for SharePoint Foundation to include them on the list.
And here:
http://stefan-stanev-sharepoint-blog.blogspot.com/2010/03/contenttypebinding-vs-contenttyperef.html
One ugly thing about it is that you specify a site content type to be
attached to the list based on that list definition but the framework
doesn’t provision the fields in the content type if they are missing
in the list – so you need to add manually all content type’s fields in
the Fields element of the list schema file. This is actually what I
called the fields’ redefinition issue...
So duplicated Field element below from the content type definition to list schema:
<Fields>
<Field DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Group="Custom"
Overwrite="True"
Type="Lookup"
ShowField="Title"
List="Lists/LinkCategoryList"
WedId="~sitecollection" />
</Fields>
I can confirm that using Inherits="False" & <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" /> does remove the title field.
Here's another good link about Inherits="False" for those who stumble upon this post.
https://sharepoint.stackexchange.com/questions/2995/mysteries-of-the-contenttype-inherits-attribute

How to programmatically disable buttons or add/remove items from dropDown with Office Ribbon UI

I have written a simple C++ COM Office add-in that loads a ribbon XML definition and displays a simple ribbon tab. It features some buttons and a dropDown (combobox/droplist). I can handle button click events and combo selection change events like a charm.
Now I want to update ribbon UI according to changes in the active document so that some buttons are disabled and some items added/removed from combobox.
I have searched up and down and could not find a way to control this. Am I missing something very obvious? How can I change button enabled state from anywhere in my code?
The way I've seen it done, using the Windows Ribbon control: the extra buttons must be specified in the XML markup, at design time. At runtime, you call SetModes() to specify which sets of widgets gets displayed in the ribbon.
Like this:
<Application.Views>
<Ribbon>
<Ribbon.Tabs>
<Tab CommandName="cmdTabMain" ApplicationModes="0,1">
<Group CommandName="cmdGroupCommon"
SizeDefinition="ThreeButtons"
ApplicationModes="0,1">
<Button CommandName="cmdButtonNew" />
<Button CommandName="cmdButtonOpen" />
<Button CommandName="cmdButtonSave" />
</Group>
<Group CommandName="cmdGroupSimple"
SizeDefinition="TwoButtons"
ApplicationModes="0">
<Button CommandName="cmdButtonSwitchToAdvanced" />
<Button CommandName="cmdButtonDropA" />
</Group>
<Group CommandName="cmdGroupAdvanced"
SizeDefinition="FourButtons"
ApplicationModes="1">
<Button CommandName="cmdButtonSwitchToSimple" />
<Button CommandName="cmdButtonDropA" />
<Button CommandName="cmdButtonDropB" />
<Button CommandName="cmdButtonDropC" />
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>
Then (in C# anyway) in the click handler, you do _ribbon.SetModes(1) or _ribbon.SetModes(0).