Setting Component Property from REDHAWK Control Panel - redhawksdr

I'm working on a REDHAWK control panel. I've been able to bind an SCA Component property to an SWT Text widget and keep them in sync. However, I cannot find a method to set an SCA Component property from a REDHAWK control panel. For example, I am trying to set the value of a simple float property in an SCA Component after an SWT Button widget is pressed (using a SelectionEvent).
Is this something that I should expect to be able to do? If so, how? I dug through the gov.redhawk.core code, but didn't have any luck.
Thanks!

In order to update component property you will need to get a locked reference to the SCA simple property. This is done as follows
ScaModelCommand.excute(property, new ScaModelCommand(){
#Override
execute()
{
property.setValue(newValue)
}
});

Related

Computing rendered property of xp:messages control

On my xpage I have an xp:messages for which I have adapted the UI to Boostrap/corporate standard.
Therefor I have placed the control inside a xp:panel control.
I wonder how I could compute the rendered property of this panel based upon if the xp:messages control has any items in it or not. I could not find an answer on SO.
If you display inside the message component an error, you can check the FacesContext.getMessage()
For more details see the answer, Get error messages

disable key entry in pe:timePicker inside a p:datatable

How do I disable keyboard entry in a primefaces extensions timePicker inside a primefaces datatable ? There is no property by default like p:calendar.
Can i do it via js ?
I have to either disable keyboard entry or manipulate the component such that it hides the popup and the user can only type in values. Tried the latter using css but it failed. Please help.
Thanks !
As far as I am aware you can't do it on the component itself...YET.
What has worked for me with JSF regarding a similar issue was the Javascript/Jquery approach. For instance you take an Id or a class of certain component you want to disable the keyboard on and do the following.
$(document).ready(function() {
$("#yourComponentId").keydown(false);
});
or this:
...
$(".yourComponentClassname").on("keydown keypress keyup", false);
...
As far as I am aware if you give the component an attribute like:
... readonly = true ...
your backing bean will ignore it unless you mess around with:
FacesContext#getRenderResponse();
Hope this helps a bit.

Want to create a custom component that mirror existing component functionalities, but using different renderer

The JSF component SelectOneRadio layout is very limited so I wrote a custom Renderer for it, and it works great. However, there are times when I want to use the standard SelectOneRadio layout as well. So I decide to make my new component that utilize the custom Renderer I create, but I want this new component to mirror the functionality of SelectOneRadio, and the only different is that it will use my Renderer. Do I need to create both custom tag and custom component to go with my custom renderer in this case? What class should I extends to obtain all functionalities from SelectOneRadio? I would greatly appreciated if you can provided some codes.
EDIT
#BalusC: I like your idea about detecting the value of layout to delegate the correct renderer. So if I have layout="div_layout", then it works great, but if it is pageDirection or lineDirection and nothing show up. What I did is: I create a class that extends MenuRenderer and I override encodeEnd method, so in there I did this
String layout = (String) component.getAttributes().get("layout");
if(layout != null){
if(layout.equals(PAGE_DIRECTION) || layout.equals(LINE_DIRECTION)){
super.encodeEnd(context, component);
return;
} else if (!layout.equals(DIV_LAYOUT)){
//Throw error message
}
}
//Continue with my own renderer code
EDIT2
Above when I said nothing show up, I was wrong. super.encodeEnd(context, component); did render, but instead of render the radio, it render select option tag. So it seems that I delegate to the wrong renderer. I need to use RadioRenderer instead of MenuRenderer.
If it's specific to your own web application, then you could replace just alone the renderer. Easiest is to extend the implementation specific renderer and then depending on the value of one of the standard attributes (layout is the best choice) either delegate to the implementation specific renderer, or do your own custom rendering job.
I case of Mojarra, you'd like to extend com.sun.faces.renderkit.html_basic.RadioRenderer and then register it as follows
<renderkit>
<renderer>
<component-family>javax.faces.SelectOne</component-family>
<renderer-type>javax.faces.Radio</renderer-type>
<renderer-class>com.example.ExtendedRadioRenderer</renderer-class>
</renderer>
</renderkit>
If you wish to be implementation independent, then you'd need to write the entire renderer implementation yourself.
If you wish to have a custom component for it, then you'd need to write it yourself as well.

Bind UIElement to viewModel

I have a simple view containing a richtextbox and a button. I want to enter text into my RTB and on clicking my button have viewmodel print the RTB.
I have my command set up from the views print button and in my viewmodel have a UIElement property.
My question is how do I bind the RTB directly to my UIElement property in viewModel?
I'm fine with hooking individual properties of the RTB up but what about the whole control?
Not certain how you might accomplish that using databinding, how about just setting the reference manually?
MyControl.Loaded += (s, e) => {
((ViewModel)MyControl.DataContext).UiElementProperty = MyControl;
};
... although I'm not sure why you want to perform a task like that in the VM. How about just handling it in the view? Otherwise you might also encounter "dialogue must be user initiated" type errors.

How does MonoTouch autogenerate XIB code behind?

I'm a C# programmer dabbling in a bit of iPhone development using MonoTouch.
I add a new View Interface Definition to my project and double click to open it up in Interface Builder. I add a UIButton. I save the file, and inspect the xib.designer.cs file, and I can see no reference to the new button.
I downloaded the code from http://monotouchexamples.com/ where I could see an example of autogenerated code behind :
[MonoTouch.Foundation.Connect("infoButton")]
private MonoTouch.UIKit.UIButton infoButton {
get {
return ((MonoTouch.UIKit.UIButton)(this.GetNativeField("infoButton")));
}
set {
this.SetNativeField("infoButton", value);
}
}
I opened up MainWindow.xib in interface builder. I notice a few differences. File's Owner is of type UIApplication instead of NSObject. What is the importance of this? There is an App Delegate object of type AppDelegate. I can't add an AppDelegate to my own view, or at least I can't find it in the Library. Do I need to add one? I can see that the existing controls on MainWindow.xib have Referencing Outlets to the App Delegate. I add a new button and I want to hook it up. When I click and drag a New Referencing Outlet to the App Delegate a context menu appears that lists the existing controls. How do I add a new element to this list, or where does this list come from?
I've been spoilt by the Visual Studio world where I just dump a button on a form and start writing code for the click event. Could someone provide some pointers about the steps needed to get this working on MonoTouch?
Thanks,
Patrick
Adding a button by itself is not enough. The button is not accessible outside the Interface Builder. You need add an Outlet, and connect the button with the outlet in Interface Builder.
Remember: Outlets are the members in your Controller class that get a reference to the controls, you can't just access the controls without them.
As Dave says, you need to add an outlet to your controller class, and connect your button to that outlet, before any auto-generated code will appear. This caught me out too initially.
You choose your controller class in the Interface Builder library window, choose 'outlets' in the bottom part of the library, and add an outlet there. You then need to select your button, choose the connections tab of the inspector window, and drag from the "New referencing outlet" circle over to your controller class. Interface Builder will then prompt you to choose an outlet to connect to. Then when you save, you should get the auto-generated code appear in the .xib.designer.cs file, and then you should be able to reference your button via that outlet variable in your .xib.cs file.
It sounds like the project I created is out of date - I remember there were quite a few changes around how the generated buttons are created in the designer file. I will update the project soon for you.
As Dave said, to get the code to be auto generated you need to add an outlet with Interface Builder. There should be an example on this video here - http://bit.ly/aWoItN but the server seems to be down at the moment.
Hope this helps,
ChrisNTR

Resources