Injection From Pages.xml (Seam) - seam

Does anyone know if I can inject value from pages.xml into a Seam component? In pages.xml there seems to be an in element that would indicate I can but I can't figure out how to use it & documentation is lacking.
I'm trying to set a value in a component that varies from page to page. It needs to be set for page load & I don't want it exposed to the user. Here's what I've tried at the moment:
<page view-id="/daily.xhtml">
<in name="chartLoader.reportType" value="DAILY"/>
<action execute="#{chartLoader.loadData}" />
</page>
<page view-id="/hourly.xhtml">
<in name="#{chartLoader.reportType}" value="HOURLY"/>
<action execute="#{chartLoader.loadData}" />
</page>
Neither of these work now with an error of:
javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
The reportType property is private but it has the correct public setter method. So I'm thinking that my syntax is slightly off.
Does anyone know how to use this element correctly or have a better suggestion?
Thanks,
Lee

Try this instead
<action execute="#{chartLoader.setReportType('DAILY')}"/>

Related

Spring MVC: Does <Form:Label> really solves any additional purpose or is it okay to use HTML label tag?

Does Form:Label class and path solves any purpose?
<form:label class="boldText" path="comments.commentOnChild">
<spring:message code="label.commentOnChild" />
</form:label>
What if we write statement simply in -label- tag? What additional benefits does form:label provides over HTML Label? What if i do not use Form:Label at all?
As we know that <form:label /> tag is associated to spring so it will have access to the model and binding results also and it can use another css class in case of any error.
<form:label cssClass="title" cssErrorClass="title error" path="student" />
In case of error this code will render differently than the normal label.You could also do this with normal tag but for that you need to include some logic into your pages, which will be extra you will be doing.
The <form:label /> tag has access to the underlying model and binding results through path variable and as such can, on error, use another style class.
The <spring:message /> tag provides you with internationalization support using Spring's MessageSource concept. The MessageSource is an interface providing functionality for retrieving messages. It closely resembles JSTL's fmt:message-tag, however, the MessageSource classes can be integrated with the Spring context. Also, the <spring:message /> tag, works with the locale support that comes with Spring.
Also you can do this without the form tag but that would mean you need to include some logic into your pages but it isn't advisable.

How to deal with "The ID '...' is already used by another control when conditionally removing controls?

I have a custom control that currently conditionally renders content:
<me:CustomControl>
<switch>
<if "expression is true">
<textbox id="Name" />
</if>
<if "expression is true">
...
</if>
<else>
<textbox id="Name" />
</else>
</switch>
</me:CustomControl>
My example above makes no logical sense, but gets straight to the point. The <if> tag is evaluated by overriding the GetChildControlType function. The <textbox> inside is evaluated in the <if>'s control builder.
What I want to do is completely remove the control from the collection, or even better yet, prevent child controls of <if> from being added to the collection to begin with. If I try to remove them OnInit, I still get the error "The ID 'Name' is already used by another control."
I can't evaluate them in the:
Public Overrides Function GetChildControlType(ByVal tagName... ) As Type
Because I need to perform logic on all the if's and else's within it.
Maybe there's a better way?
Update
I get a compilation error even if I break this thing down to bare bones if there are more than one controls with the same ID, even though overriding CreateChildControls. not sure if I can get around this at all.

Alfresco multi-select action icon

I am working on a custom action in Alfresco. I want the action to be available as both multi select and as well as action for each items. If I add new action I could see the icon. But in multi select the action icon is not displaying. How to display image to the multi select actions?
Here is my code:
The OOTB multi-select actions for the Document Library can be found in the share-documentlibrary-config.xml file.
<multi-select>
<action type="action-link" id="onActionDownload" icon="document-download" label="menu.selected-items.download" />
<action type="action-link" id="onActionCopyTo" icon="document-copy-to" label="menu.selected-items.copy" />
<action type="action-link" id="onActionMoveTo" icon="document-move-to" permission="Delete" label="menu.selected-items.move"/>
<action type="action-link" id="onActionAssignWorkflow" asset="document" icon="document-assign-workflow" label="menu.selected-items.assign-workflow"/>
<action type="action-link" id="onActionDelete" icon="document-delete" permission="Delete" label="menu.selected-items.delete" notAspect="hwf:hybridWorkflow,sys:undeletable" />
<action type="action-link" id="onActionCloudSync" asset="document" icon="document-cloud-sync" permission="CreateChildren" label="menu.selected-items.cloudSync" notAspect="sync:syncSetMemberNode" syncMode="ON_PREMISE" />
<action type="action-link" id="onActionCloudSyncRequest" icon="document-request-sync" label="menu.selected-items.cloudRequestSync" hasAspect="sync:syncSetMemberNode" syncMode="ON_PREMISE" />
</multi-select>
If you want additional multi-select actions to be displayed then you will want to augment this configuration attribute. Rather than editing this file directly you'll want to provide an extension to this particular configuration section (you can find some documentation of this here)
It would be worth reviewing how the existing multi-select actions are implemented to ensure that your custom action is compatible as both a single item action and a multi-select action
Looks like this is done by overwriting some of the ootb javascript, specifically the toolbar.lib.js and the toolbar.get.config.xml.
It's obfuscated in the title, but I believe this post answers your question:
How to extend toolbar.get.config.xml in Alfresco Share

How to implement conditional transitions in Spring Webflow

Just getting the hang of Spring Webflow. I have some simple forms working and binding back and forth - very cool. One thing not obvious to me at the moment is how to dynamically launch a flow based on user input.
i.e. imagine a flow where the user chooses an option in the first screen, and based on the choice taken, different subflows can be initiated. In pseudo-terms something like the following pseudo-flow:
<view-state id="selectService" model="serviceType">
<transition on="proceed">
<if "serviceType.selectedValue==1" to="subFlow1" />
<if "serviceType.selectedValue==2" to="subFlow2" />
<if "serviceType.selectedValue==3">
<if "serviceType.isValid==3" to="subFlow3" />
</if>
<default to="cancel" />
</transition>
<transition on="cancel" to="cancel" />
</view-state>
I've trawled the examples, docs, stackoverflow and the spring forums but haven't seen this anywhere..
It is covered in Spring in Action 3, which is a great book for Spring development in my eyes.
To answer your question here though, I think you are looking for the decision-state transition element. To get to user input, you should be able to use Spring Expression Language (SpEL) in the test attribute.
I tried using the decider recently, but frankly, for any non-trivial logic, it's best to move it to a Java method where you can easily unit test it. Then call said method and use the output from there. It's best to keep the flow XML files as simple as you can.

Custom ASP binding mechanism problem

know ASP since about 6 months, and I've go hard problem. I've created my own DataBinding mechanism and I need some solution to do somthing like this:
I have this example code in my ASPX
<myButton id="someID" runat="server" Text="SomeText" BackColor="{SomeContext}" />
and I have in this control my property Context of type Object. I want to bind property which is inside Context to BackColor property. Name of the property from Context is SomeContext (in brackets). All I need is to use some TypeConverter or other technology to identify that there is a name inside {} and remember that name inside instance of myButton control. Any ideas???
I thought that I can use my own class inherited from TypeConverter and catch the moment of converting value {SomeContext} to Color (the BackColor property). I can catch this moment, but I have no info about target control, only empty context of String value. If anyone know how to get target property somehow, will be very!! helpful.
I've been searching web, and nothing...
You can set this in your code behind directly:
someID.BackColor = context.Color;
Ya might give ASP.NET Custom Expression builders a try.
I won't use codebehind in my project. Website will be rendered from compiled customized aspx from database. I have special approach for my system, and my binding is a main part of it. Regular databinding expression won't help because it use ASP binding, which I don't want to use.
Unfortunately I didn't find any solution of my problem, so I decided to use inner properties. I'll use ASPX code like this:
<myButton runat="server" ID="someID">
<Binding>
<Bind Target="BackColor" Source="ColorOfBackgroundFromContext" />
<Bind Target="ForColor" Source="ColorOfForegroundFromContext" />
</Binding>
</myButton>

Resources