Populating ListBox in wix installer - listbox

I have created a ListBox in my wix project and i want to populate that ListBox with values coming from the custom action. What i want is that on click of a button my custom action should get called and further my ListBox should get populated. I don't know what is going wrong. So, if anyone knows how to do it, please help. Thanx in advance.
Code in My Custom Action:-
Database db = session.Database;
string var = db.Tables["ListBox"].SqlInsertString + "TEMPORARY";
Microsoft.Deployment.WindowsInstaller.View var2 = db.OpenView(var);
var2.Execute(new Record(new object[] {"PROPERTY NAME", 5, "5", "value"}));
var2.Close();
Code in Wix project:-
<Control Id="ANY ID" Property="PROPERTY NAME" Type="ListBox" X="20" Y="20" Width="300" Height="300" Sorted="yes">
<ListBox Property="PROPERTY NAME">
<ListItem Text="[PROPERTY NAME]" Value="[PROPERTY NAME]"/>
</ListBox>
</Control>
Code on Button for Calling Custom Action and refreshing value of property that is set on ListBox:-
<Control Id="ANY ID" Type="PushButton" Text="[Next]" Height="200" Width="200" X="160" Y="160" Bitmap="yes" FixedSize="yes" Default="yes">
<Publish Event="DoAction" Value="CustomAction">1</Publish>
<Publish Property="PROPERTY NAME" Value="[PROPERTY NAME]" Order="2">2</Publish>
</Control>
After all this, I am not able to see the value that is being inserted to the table in CustomAction or in other words, the ListBox is not getting populated after doing all this.

It will not work this way.
We have to call the Custom Action On load of the next dialog.
This works for me:-
<InstallUISequence>
<Custom Action="NAME_OF_CUSTOM_ACTION" Before="DIALOG_NAME_ON_WHICH_YOU_WANT_TO POPULATE_THE_LISTBOX"/>
<Show Dialog="DIALOG_NAME_ON_WHICH_YOU_WANT_TO POPULATE_THE_LISTBOX"
After="PREVIOUS_DIALOG_NAME"/>
</InstallUISequence>

Related

XUL get the value of MENUITEM selected

I am creating a dropdown in XUL like this:
<button id="bid" oncommand="alert(event.target.nodeName)" >
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</button>
I want to alert the value of nodeitem which is being clicked. Using event.target.nodeName giving nodeName as menuitem but using nodeValue is retuning undefined as it starts to take value of button node. How can I get the value of the menuitem clicked. I also tried $(this).val() but even that gave undefined. Using $(this).attr('value')
also didn't help. I can put oncommand for menuitem but that doesn't seem to be actual solution. Is that the only way or some method exist to get the value?
The XUL code you have in the question is non-functional. Either you should be using a <menulist> instead of a <button>, or your <button> needs the property type="menu" or type="menu-button". If you are going to use a <button> without the type="menu" property, you would actually have to open a popup in the command event handler for the <button> and then select from there. That does not appear to be what you are wanting. It is, however, quite doable. I use a construction like that in one of my add-ons, except I have it open when one of several <label> items is clicked. This allows re-use of a single <menupopup> for multiple different items in the window. In that case, the <menupopup> is a rather large amount XUL code that I did not want to repeat and maintain multiple duplicates in the XUL for the window.
The value of the <menuitem> selected:
Your actual question is how to get the value of the <menuitem> selected by the user. All of the code below is tested and functional. As you can see from the code you can get the value of the <menuitem> you select (at the time of selection) from: event.target.value.
Using a <menulist> element:
The most common element to use would be a <menulist>. This would normally be used when you are having the user select from multiple options a choice that is going to be remembered and used later, or used to adjust what is presented in the user interface. It would generally not be used to select from multiple immediate actions (which are acted upon and the choice not remembered). A <menulist> is what is used in the examples for <menuitem> and <menupopup> on MDN.
<menulist id="bid2" oncommand="alert(event.target.value)" >
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</menulist>
The above code will give you what looks like a button with a selection of <menuitem> entries when you click on it. It will alert with the value of the <menuitem> you have selected.
This will produce an item that looks like:
Which you can click on to open a drop-down list:
If you select an item:
You will get an alert:
And the object will then show your selection:
Using a <button> element:
It is also possible to use a <button> element with the property type="menu" or type="menu-button" specified. However, this provides no visual feedback to the user as to which option is currently selected. [Note: Your JavaScript could manually change the <button> label property to provide this feedback.] You could use this type of element if it is button that produces an immediate action rather than a selection that is remembered.
The code:
<button type="menu" id="bid2" label="A Button" oncommand="alert(event.target.value)">
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</button>
This will produce an item that looks like:
Which you can click on to open a drop-down list:
If you select an item:
You will get an alert:
And the object will then NOT show your selection:
If you want to set the label of the <button> to reflect the selection made by the user, you could use:
<button type="menu" id="bid2" label="A Button" oncommand="event.target.parentElement.parentElement.label=event.target.value;alert(event.target.value)">
<menupopup>
<menuitem label="one" value="one" />
<menuitem label="two" value="two" />
<menuitem label="three" value="three" />
</menupopup>
</button>
When three is selected, that will result in a button that looks like:
Using a <toolbarbutton>:
You could, alternately, use a <toolbarbutton>.
When not hovered, doing so would look like:
When hovered:
When open for selection:
Choices in UI design:
There are many choices that you have to make when designing your user interface. There are many different ways to get to the same effective result, with somewhat different look and feel. You really should be trying these types of options on your own. You may find the XULRunner program XUL Explorer to be of use when prototyping XUL.
Selecting UI elements and a look and feel is, in my opinion, beyond the scope of questions on stackoverflow. While you probably won't get specific XUL help, you can ask UI design questions at: the User Experience stack exchange.

zk nested forEach

I have following structure to display in zul file and got List of clinic object from Java controller.
I tried several zk components in zul with no luck. What component should I use with a forEach?
ListBox
ListItem
Grid
Here is structure need to display :
For each clinic
{
For each clinic.location
{
For each (clinic.location.provider)
{
Output (provider display name)
}
Output (clinic name)
Output (clinic.location address)
Output (clinic.locatoin telephone number)
Output (clinic.web address)
}
}
As explained in the answer given by Darius, here is an example of how to use a <Grid> with a <rows> component
<?page title="Result"?>
<zk>
<window apply="org.zkoss.bind.BindComposer"
viewModel="#id('vm') #init('fully.qualified.viewmodel.classname')"
title="Result Window" border="normal" >
<div>
<grid>
<rows>
<row>
<listbox model="#bind(vm.listname)">
<listhead>
<listheader label="Item Name"
style="text-align:center;">
</listheader>
<listheader label="Attribute Value"
style="text-align:center;">
</listheader>
<listheader label="Qualifier Value"
style="text-align:center;">
</listheader>
</listhead>
<template name="model" var="item">
<listitem value="${item }">
<listcell label="#load(item.name)"
style="text-align:center;">
</listcell>
<listcell
style="text-align:center;">
<textbox
value="#bind(item.attributeValue)"
style="text-align:center;" />
</listcell>
<listcell
label="#load(item.qualifierValue)"
style="text-align:center;">
</listcell>
</listitem>
</template>
</listbox>
</row>
</rows>
</grid>
</div>
</window>
</zk>
You can use a Listbox or a Grid.
If you use a Listbox, it will contain Listitem objects
If you use a Grid, it will contain a Rows object, which will contain Row objects
To the Listitem or the Row, you will add other components: the simplest would be Label objects
I notice you have an inner table of providers. For these, you will probably need a nested Grid or Listbox. You could also use ZK's Detail component. it would allow you to expand in order to see the inner table.
There are multiple ways how to achieve this
including separate zul file to template row, whitch will contain a grid with separate view model - this style you can have shown all nested grid at once ,but it should and it will have performance issiues with larger ammout of data(because count of rows == count of viewmodels of nested grids)
include nested grid with own template ,and data model as parameter of view model,and show this grid on demand(button click,row click etc) - this is bether way in case of no performance issues,but you will be able to show only one nested grid at time
Final words - just donĀ“t
Nesting a grid to grid is a very bad design,because it is incredibly hard to render this,and it is only usable for small data. The best way to do this,in my opinion is to create two separate grids,side by side,and show adition data on in second grid,after a click on row in first grid. This way you can achieve very fast gui with no performance issiues,ever with a lot of data. Another way is to create a popup on grid row,whitch will show additional data,a it is also a lot bether for your performance.

Silverlight 3.0 and MVVM Pattern

i am working on this article here they are using Silverlight 4.
link text
but i am using Silverlight 3.but for button we are not able to find the command
Command="{Binding Path=DataContext.GetPerson, ElementName= LayoutRoot }"
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="53,112,0,0" Name="button1"
VerticalAlignment="Top" Width="75" Command="{Binding Path=DataContext.GetPerson, ElementName= LayoutRoot }"
CommandParameter="{Binding Path=Age, ElementName=hi}" />
so in Silverlight 3 what should i do to get this Command property for the button
any help would be great
A command is a bindable way of associating an action to a control (button for instance).
The command controls 2 things:
whether it can be executed
what to do when it's executed
by implementing the ICommand interface
They've been around for a while in WPF and were recently added to SL4
If you want your code to work in SL3 you'll have to bind the IsEnabled property to a property in your view model that has the same logic as the CanExecute implementation of the command
and to add a Click event handler for the button which has the same logic has the command's Execute
Also, this button passes a parameter to the command (CommandParameter), you'll have to handle passing this parameter manually
You could use a framework like prism, add the relevant dll's to your project, then add a reference to the top of page like so
xmlns:prism="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
Then declare the prison attribute on your button
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="53,112,0,0" Name="button1"
VerticalAlignment="Top" Width="75" Command="{Binding Path=DataContext.GetPerson, ElementName= LayoutRoot }"
prism:Click.Command={Binding SomeCommand}
prism:Click.CommandParameter="{Binding Path=Age, ElementName=hi}" />

WPF Binding Button.Command in ControlTemplate to property of ViewModel

My ViewModel has a property called Commands which is of type IDictionary.
For my data grid I have created a ControlTemplate for one of the fields using a button as follows:
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Button Style="{DynamicResource btnRemove}" Width="14" Height="14"
Content="{TemplateBinding Content} "
CommandParameter="{Binding ViewID}"
Command="{Binding Commands[AcknowledgeErrorCmd]}" />
<ControlTemplate.Triggers>
</ControlTemplate.Triggers>
</ControlTemplate>
Clicking on the button does nothing which tells me the binding did not work. However, an unstyled button added to the toolbar of the same window hosting this grid works, binds properly to this command. I guess my question is:
Hw do I bind the command property of a button used in a ControlTemplate to a ViewModel?
TIA.
I am not sure what the problem is but try to debug your solution and look into the output window with Debug selected in the combobox and you will see the errors that occur during binding. Maybe this will help you to the solution.
Provide me the error as a comment on this post if you don't understand it.
I did this instead:
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Border >
<TextBlock Margin="5">
<Hyperlink
CommandParameter="{Binding ElementName=root, Path=DataContext.ViewID}"
Command="{Binding ElementName=root, Path=DataContext.Commands[AcknowledgeErrorCmd]}">
<TextBlock Text="Acknowledge"/>
</Hyperlink>
</TextBlock>
</Border>
</ControlTemplate>
and that works fine. It may be related to the post Viko provided.

Placing common contols in two tab pages

I have a tab item with 2 tab pages. I want to place 4 check boxes in each of the tab pages with all check boxes having the same property. How it can be done easily?
Bind all your checkboxes to the same property (from your ViewModel, you do have one, right?). Then they will all display the same information.
There's not much to the binding code.. You could try something like...
<TabControl>
<TabItem Header="Tab1">
<StackPanel>
<CheckBox Content="One" Checked="{Binding Path=MyProperty}"/>
<CheckBox Content="Two" Checked="{Binding Path=MyProperty}"/>
</StackPanel>
</TabItem>
<TabItem Header="Tab2">
<StackPanel>
<CheckBox Content="Three" Checked="{Binding Path=MyProperty}"/>
<CheckBox Content="Four" Checked="{Binding Path=MyProperty}"/>
</StackPanel>
</TabItem>
</TabControl>
..where MyProperty is a local property representing the state you want to show.

Resources