How to make components rendered via {{component}} helper independent - ember.js

I have few instances of component (let's call it <Row />) with given template:
{{component #resultComponentName result=#result}}
I'm calling <Row /> component from <Terminal /> component like this:
{{#each #rows as |row|}}
<Row #result={{row.result}} #confirm={{fn this.confirm}} #resultComponentName={{this.resultComponentName}}/>
{{/each}}
<Terminal /> component has property:
#tracked resultComponentName;
which is handled in action confirm() in <Terminal /> component:
if (cmd.resultComponentName) {
this.resultComponentName = cmd.resultComponentName;
} else {
this.resultComponentName = 'result-component';
}
where cmd is some Ember Model with property:
#tracked resultComponentName = 'other-result';
now I want to change #resultComponentName in only one instance but when I am changing #resultComponentName all of the component <Row /> instances re-render.
How can I prevent that behavior and make every instance independent?
Thanks in advance!

Your problem is that #tracked resultComponentName; exists in your Terminal component, and so only once for the entire list.
Now I'm not sure how your #rows is related to cmd here, because thats the interesting question. If each row is a cmd you could just do this:
<Row #result={{row.result}} #confirm={{fn this.confirm}} #resultComponentName={{row.resultComponentName}}/>
If its different it totally depends how you want to map for which rows you want which resultComponentName and where you want to store that information. You maybe even want to move that login into the Row component itself.

Related

SAPUI5 List CustomListItem / Rerender Issue

I got a split-app, left Hand side a master list with persons. right-hand side a Detail page with info and RatingIndicator element. Two lists on the detail-page which are bound via associations: /Master/Detail/Rating.
Whenever I use the Rating Indicator, it seems like the page is rerendering, which makes everything slow at the end. I tried both, two-way binding and one-way-binding with manually updating the model. It still rerenders/reloads the page every time I use the Rating indicator.
Any idea someone?
SAPUI5 library is on Version 1.28.31.
Edit: In the meantime I reduced complexity (no lists within lists, thought this might be the issue, but it isnt), and still the issue occurs. Even now when I use the Rating indicator the whole Detail page reloads/rerenders.
What can I do?
Before Clicking the Rating indicator:
Directly after cliking the Rating indicator, right-hand Detail page disappears and reappears withing seconds.
View:
<mvc:View controllerName="split.controller.Detail" xmlns="sap.m"
xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:footerbar="sap.ushell.ui.footerbar"
xmlns:f="sap.ui.layout.form" xmlns:l="sap.ui.layout">
<Page id="page" navButtonPress="onNavBack" showNavButton="{device>/system/phone}"
title="{i18n>detailTitle}" busy="{detailView>/busy}"
busyIndicatorDelay="{detailView>/delay}" class="sapUiResponsiveContentPadding">
<content>
<List items="{ path: 'WorklistToDocument' }">
<CustomListItem>
<VBox class="sapUiSmallMargin" }">
<Title titleStyle="H3" text="{Title}" }" />
<Text text="{Description}" }" />
</VBox>
<VBox class="sapUiSmallMargin">
<Text text="{Description}" />
<CheckBox selected="{NotApplicable}" select="onNACheckBoxSelect" />
<RatingIndicator value="{RatingValue}" maxValue="{MaxValue}" change="onRatingChanged" />
<Text
text="{ path: 'RatingValue', formatter: '.formatter.ratingText' }" />
</VBox>
</CustomListItem>
</List>
</content>
</Page>
Controller:
onRatingChanged: function(oEvent) {
var oSource = oEvent.getSource();
var oModel = this.getModel();
var sPath = oSource.getBindingContext().sPath;
var sCtxPath = sPath + "/RatingValue";
var sCtxPathNA = sPath + "/NotApplicable";
var iValue = oEvent.getParameter("value");
oModel.setProperty(sCtxPath, iValue);
oModel.setProperty(sCtxPathNA, false);
},
Is this line
var sCtxPath = sPath + "/RatingValue";
not leading to another "change" event trigger?
Additionally, is there a loop in your formatter that could cause a 'hang'?
And what about any events in your master with the same odata path?

Add extended Scroller to extended spark List in Flex

I'm trying to add a custom Scroller.as (extended from spark.components.Scroller) to a InfiniteScrollList.as (extended from spark.components.list)
I wrote the following MXML code:
<list:InfiniteScrollList width="100%" height="100%" id="EventsList" useVirtualLayout="true">
<list:scroller>
<list:Scroller/> <!-- The Scroller.as Class -->
</list:scroller>
</list:InfiniteScrollList>
The List behavior works well but the extended Scroller component does not function at all.
What is the correct way to add this scroller functionality (in MXML or ActionScript) to the list?
The s:Scroller is used by wrapping it around the content or DataGroup. But the List class wraps all that functionality inside of it's skin, so I believe that in order to create a custom Scroller for a List, you actually need to do within the SkinClass.
<list:InfiniteScrollList width="100%" height="100%" id="EventsList"
useVirtualLayout="true" skinClass="MyListSkin" />
MyListSkin.mxml:
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minWidth="112">
<fx:Metadata>
[HostComponent("spark.components.Scroller")]
</fx:Metadata>
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
</s:states>
<!-- The Scroller.as Class -->
<list:Scroller left="0" top="0" right="0" bottom="0" id="scroller" hasFocusableChildren="false">
<!--- #copy spark.components.SkinnableDataContainer#dataGroup -->
<s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer">
<s:layout>
<!--- The default layout is vertical and measures at least for 5 rows.
When switching to a different layout, HorizontalLayout for example,
make sure to adjust the minWidth, minHeight sizes of the skin -->
<s:VerticalLayout gap="0" horizontalAlign="contentJustify" requestedMinRowCount="5" />
</s:layout>
</s:DataGroup>
</list:Scroller/>
</s:SparkSkin>

Sharepoint Deploy new Column to list

I'm fairly new to SharePoint 2010, I've had some experience with 2007 but only debugging and fixing some small bug.
Assuming that i create a new solution for SP 2010 in VS2010 and i add a feature to create some list definitions and also some list instances of those list definition templates. These are all declared through Schema.xml =>
I deploy successfully and add a few items to my new lists.
Now i want to add a few extra columns (fields) to my lists, how will i deploy them?
I don't want to create them in code, i would like to have a up to date solution that with every new developer a simple deployment would create an up and running Dev environment.
What is the correct way to do the deployment in this case?
If you have the schema.xml file defined for the list, then you really want to add your new columns using the collection within the list definition. You also want to be sure your list is defined by a content type, allowing for reuse. So within your schema.xml file, it would look something like this:
<List xmlns:ows="Microsoft SharePoint" Title="Test List" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Test-List" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<ContentType ID="0x010068a2e063a1a74913a37ecdb61ab2c721" Name="Test" Group="Custom Content Types" Description="Test Description" Inherits="TRUE" Version="0">
<FieldRefs>
<FieldRef ID="{c2f80e7d-666e-4273-8b58-d5c8a13a9d6a}" Name="Col1" ShowInNewForm="TRUE" Required="TRUE" ShowInEditForm="TRUE"/>
<FieldRef ID="{a84d620a-d42d-455c-8ef8-7e9f1d443250}" Name="Col2" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE"/>
<!-- Your new field refs here here -->
</FieldRefs>
</ContentType>
</ContentTypes>
<Fields>
<Field ID="{c2f80e7d-666e-4273-8b58-d5c8a13a9d6a}" Type="Text" AllowDeletion="FALSE" Description="Key" AllowDuplicateValues="FALSE" EnforceUniqueValues="TRUE" Indexed="TRUE" Name="Col1" DisplayName="Col1" Group="Custom Columns" />
<Field ID="{a84d620a-d42d-455c-8ef8-7e9f1d443250}" Type="Text" AllowDeletion="FALSE" Name="Col2" DisplayName="Col2" Group="Custom Columns" />
<!-- Your new fields here -->
</Fields>
...
</MetaData>
</List>
Don't forget to change your View as well!

Passing parameters as parameters in templates in JSF 2.0

I'm having difficulty finding support on this topic, because I know how to pass parameters to a template. What I want to do is pass parameters to not be used as parameters to the template but to a component within the template.
For example, in primefaces, you can write the following logic to create a button:
<p:commandButton action="#{printBean.print}">
<f:attribute name="report" value="report.jrxml" />
</p:commandButton>
This is all fine and good when I don't need to pass parameters. However, I need to construct a template which allows me to specify parameters to pass to the report dynamically. My first attempt was to do the following:
<p:commandButton actionListener="#{printBean.print}">
<f:attribute name="report" value="report.jrxml" />
<ui:insert name="reportParams" />
</p:commandButton>
Which would allow me to use the template in the following manner:
<ui:decorate template="templates/report.xhtml" >
<ui:define name="reportParams>
<f:attribute name="reportParam1" value="paramVal1" />
<f:attribute name="reportParam2" value="paramVal2" />
<f:attribute name="reportParam3" value="paramVal3" />
...
</ui:define>
</ui:decorate>
However parameters passed in this way are not received in my action listener in printBean, yet parameter "report" is. I think the attributes passed in this way are interpreted to mean that it is referring to the ui:define tag, and not to be inserted in the template as I would want.
Is there an alternative way of achieving the same way? Keep in mind I'm using JSF 2.0 and primefaces, but not Seam or any added libraries and ideally I would not have to add any libraries to make it work.
I apologize if an answer to this question already exists, but it's maddening searching for an answer to this question.
EDIT: The number of parameters is variable, meaning I can't simply use ui:param and put the value of that parameter as an attribute value within the template, because there could be many such parameters.
Use a composite component instead of a template.
Create this file /resources/mycomponents/printReport.xhtml:
<ui:component
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui"
>
<cc:interface>
<!-- No attributes. -->
</cc:interface>
<cc:implementation>
...
<p:commandButton value="Print" action="#{printBean.print}" />
...
</cc:implementation>
</ui:component>
Use it as follows:
xmlns:my="http://java.sun.com/jsf/composite/mycomponents"
...
<my:printReport>
<f:attribute name="reportParam1" value="paramVal1" />
<f:attribute name="reportParam2" value="paramVal2" />
<f:attribute name="reportParam3" value="paramVal3" />
</my:printReport>
Rewrite the print method as follows:
public void print() {
UIComponent composite = UIComponent.getCurrentCompositeComponent(FacesContext.getCurrentInstance());
String reportParam1 = (String) composite.getAttributes().get("reportParam1");
String reportParam2 = (String) composite.getAttributes().get("reportParam2");
String reportParam3 = (String) composite.getAttributes().get("reportParam3");
// ...
}

List contains method not working in JSF page

I have two list that consist out of the same object.
I want to check if the first list containts an object of the second list
<ui:repeat var="item" value="#{userTypeController.permissionItems}">
<c:if test="#{userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{true}"/>
<h:outputText value="#{item.getAction()}" />
</c:if>
<c:if test="#{!userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{false}"/>
<h:outputText value="#{item.getAction()}" />
</c:if>
</ui:repeat>
but this doesn't seem to work and all I'm getting is false.
I've changed the equals and hashcode methodes but didn't help.
JSTL tags like <c:if> runs during view build time and the result is JSF components only. JSF components runs during view render time and the result is HTML only. They do not run in sync. JSTL tags runs from top to bottom first and then JSF components runs from top to bottom.
In your case, when JSTL tags runs, there's no means of #{item} anywhere, because it's been definied by a JSF component, so it'll for JSTL always be evaluated as if it is null. You need to use JSF components instead. In your particular case a <h:panelGroup rendered> should do it:
<ui:repeat var="item" value="#{userTypeController.permissionItems}">
<h:panelGroup rendered="#{userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{true}"/>
<h:outputText value="#{item.getAction()}" />
</h:panelGroup>
<h:panelGroup rendered="#{!userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{false}"/>
<h:outputText value="#{item.getAction()}" />
</h:panelGroup>
</ui:repeat>
See also:
JSTL in JSF2 Facelets... makes sense?