I am new to this Adobe flex development.Right now I am working on the application and in my mxml form I have to place 2 fields.
one is Radio button(option (yes ,no) )and another one is text box(name), and the requirement is:
when the user selects yes then the name field should enable otherwise it should be disable.
The validation rules are:
if the user selects yes and he would not enter any value(textbox is empty) then we should display error message that "value is required"
if the user selects no and the text filed has some value then first he has to delete the contents in the textfiled then only select 'no'.
someone please help me and give me some code sample.That would be great help for me.
put this code in your MXMLapplication and run..
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="567" height="206" minWidth="955" minHeight="600" initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
}
protected function rd1_clickHandler(event:MouseEvent):void
{
if(!t1.enabled)
{
t1.enabled=true;
}
else if(t1.text=="" && t1.enabled)
{
Alert.show("Value is required in text box");
}
else
t1.enabled=true;
}
protected function rd2_clickHandler(event:MouseEvent):void
{
t1.text=null
t1.enabled =false;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextInput x="132" y="41" id="t1"/>
<s:RadioButton x="162" y="91" label="Yes" id="rd1" groupName="select" click="rd1_clickHandler(event)"/>
<s:RadioButton x="211" y="91" label="No" id="rd2" groupName="select" click="rd2_clickHandler(event)" />
<s:Label x="79" y="45" text="Name"/>
</s:Application>
Create a custom mxml control based on TitleWindow and us PopupManager to show it on display.
Related
Using Visual Studio, when selecting 'Zebble for Xamarin - Cross Platform Solution' a default project will be created with five pages. I've modified the fifth page to implement a signature pad. Below is the following Page-5.zbl code.
<?xml version="1.0"?>
<z-Component z-type="Page5" z-base="Templates.Default" z-namespace="UI.Pages"
z-partial="true" Title="About us" data-TopMenu="MainMenu" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./../.zebble-schema.xml">
<z-place inside="Body">
<TextView Text="Hello world!" />
<SignaturePad Id="sigPad1" Enabled="true" LineThickness="4" Style.Border.Color="red" Style.Width="100" Style.Height="100"/>
</z-place>
</z-Component>
Which ends up adding this line to .zebble-generated.cs:
await Body.Add(sigPad1 = new SignaturePad { Id = "sigPad1", Enabled = true, LineThickness = 4 }
.Set(x => x.Style.Border.Color = "red")
.Set(x => x.Style.Width = 100)
.Set(x => x.Style.Height = 100));
I have been looking at this SignaturePad component package: https://github.com/xamarin/SignaturePad
If I wanted to use the Xamarian SignaturePad component or anyone else's SignaturePad component instead of the Zebble SignaturePad UI component, how would I do that?
To use a third party component, all you need to do is to create a Zebble wrapper around it. It's explained here:
http://zebble.net/docs/customrenderedview-third-party-native-components-plugins
Step 1: Creating Native Adapter(s)
You should first create a Zebble view class to represent an instance of your component using the following pattern. This class will be in the Shared project, available to all 3 platforms.
namespace Zebble.Plugin
{
partial class MyComponent : CustomRenderedView<MyComponentRenderer>
{
// TODO: Define properties, method, events, etc.
}
}
Note: To make the VS IntelliSense in ZBL files recognize this, you should create a .ZBL file for MyComponent as well:
<z-Component z-type="MyComponent" z-base="CustomRenderedView[MyComponentRenderer]" z-namespace="Zebble.Plugin"
z-partial="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./../.zebble-schema.xml" />
The next step will be to create the renderer classes.
Step 2: Creating Native Renderers(s)
You need to create the following class each platform (UWP, iOS, Android).
public class MyComponentRenderer : ICustomRenderer
{
MyComponent View;
TheNativeType Result;
public object Render(object view)
{
View = (MyComponent)view;
Result = new TheNativeType();
// TODO: configure the properties, events, etc.
return Result;
}
public void Dispose() => Result.Dispose();
}
Using it in the application code
In the application code (App.UI) you can use MyComponent just like any other built-in or custom view type.
<Zebble.Plugin.MyComponent Id="..." Property1="..." on-Event1="..." />
I am using MVVMCross, and have a problem with MvxDialogFragment bindings.
I have a base service, which is resolved in Core PCL project, add custom services implementations in iOS and Android projects derived from the base service class.
In android service i construct and show MvxDialogFragment instance:
var top = (MvxFragmentActivity)Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity;
if (top == null)
{
throw new MvxException("Cannot get current top activity");
}
var dlg = new AlertDialog.Builder(top);
dlg.Create().Show();
dialog = new MyDialog
{
Cancelable = false
};
dialog.Show(top.SupportFragmentManager, "");
And i have simple dialog layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/test_click_button"
android:text="Test"
app:MvxBind="Click TestClickCommand" />
</LinearLayout>
So my goal is to acces base service commands from dialogFragment, which is instantiated from service. How can i do that?
As an alternative, i want to handle my button click in service, but cannot find a way to do this, because my View, ViewModel or Dialog properties are null.
How it's possible to handle clicks in service, or implement self binding?
Finally i achieved the desired, through MvxDialogFragment subscription, and service injection:
public class MyDialog : MvxDialogFragment
{
private ISampleService _sampleService;
public MyDialog(ISampleService sampleService)
{
_sampleService = sampleService;
}
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
EnsureBindingContextSet(savedInstanceState);
var dialog = new AlertDialog.Builder(Activity);
var view = this.BindingInflate(Resource.Layout.MyDialog, null);
view.FindViewById(Resource.Id.test_click_button).Click += (sender, e) =>
{
_sampleService.TestClick();
Dismiss();
};
dialog.SetView(view);
return dialog.Create();
}
}
I am using stacklayout panel for the first time.
I read the gwt docs and found that parent for this should be a type of Layout.
Below is my code for parent widget("EncounterViewImpl") which creates a TabLayout panel and my widget "StudyViewImpl" is on one of the tabs of this tablayout.
EncounterViewImpl.ui.xml(Parent)
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder
xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:hpi="urn:import:com.zoomcare.emrgwt.client.ui.encounter.hpi"
xmlns:history="urn:import:com.zoomcare.emrgwt.client.ui.encounter.history"
xmlns:medication="urn:import:com.zoomcare.emrgwt.client.ui.encounter.medication"
xmlns:physical="urn:import:com.zoomcare.emrgwt.client.ui.encounter.physical"
xmlns:diagnosis="urn:import:com.zoomcare.emrgwt.client.ui.encounter.diagnosis"
xmlns:wellness="urn:import:com.zoomcare.emrgwt.client.ui.encounter.wellness"
xmlns:study="urn:import:com.zoomcare.emrgwt.client.ui.encounter.study"
xmlns:dental="urn:import:com.zoomcare.emrgwt.client.ui.encounter.dental">
<g:TabLayoutPanel barUnit="PX" barHeight="30" width="100%" height="100%">
<g:tab visible="false">
<g:header>
Dental
</g:header>
<g:ScrollPanel width="98%" height="100%">
<dental:EncounterDentalViewImpl ui:field="encounterDentalView"/>
</g:ScrollPanel>
</g:tab>
<g:tab visible="false">
<g:header>
Study
</g:header>
<g:ScrollPanel width="98%" height="100%">
<study:StudyViewImpl ui:field="studyView"/>
</g:ScrollPanel>
</g:tab>
</g:TabLayoutPanel>
StudyViewImpl.ui.xml(Child)
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:StackLayoutPanel height="100%" width="98%" ui:field="stackPanel" >
</g:StackLayoutPanel>
I want to add the widgets to stackpanel dynamically by its corresponding Activity class .StudyActivity calls setStudies(List list) after getting service response
Below is the code ..
StudyViewImpl.java
public class StudyViewImpl extends Composite implements StudyView {
private static LocalUiBinder uiBinder = GWT.create(LocalUiBinder.class);
interface LocalUiBinder extends UiBinder<StackLayoutPanel, StudyViewImpl> {
}
private StudyInfoActivityPiece presenter;
#UiField
StackLayoutPanel stackPanel ;
public StudyViewImpl() {
initWidget(uiBinder.createAndBindUi(this));
//stackPanel.setWidth("800");
}
public void setStudies(List<ScheduledStudyGWT> studies){
for(ScheduledStudyGWT study : studies) {
VerticalPanel vPanel = new VerticalPanel();
vPanel.setWidth("100%");
vPanel.setHeight("100%");
StudyInfoWidget infoWidget = new StudyInfoWidget();
infoWidget.setWidth("100%");
infoWidget.setHeight("100%");
infoWidget.populate(study);
infoWidget.setReadOnly(false);
ExamNoteWidget examNoteWidget = new ExamNoteWidget();
examNoteWidget.setWidth("100%");
examNoteWidget.setHeight("100%");
examNoteWidget.setExamNote(study.getExamNote());
examNoteWidget.setReadOnly(false);
InstructionsWidget instructionsWidget = new InstructionsWidget();
instructionsWidget.setInstructions(study.getInstructions());
instructionsWidget.setWidth("100%");
instructionsWidget.setHeight("100%");
instructionsWidget.setReadOnly(false);
vPanel.setVisible(true);
vPanel.add(infoWidget);
vPanel.add(examNoteWidget);
vPanel.add(instructionsWidget);
stackPanel.add(vPanel,createHeaderWidget(study.getOrderedLab().getLab().getName()),30);
}
}
private Widget createHeaderWidget(String text) {
HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setHeight("100%");
hPanel.setSpacing(0);
hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
HTML headerText = new HTML(text);
hPanel.add(headerText);
return new SimplePanel(hPanel);
}
}
When I run the above code I see that setStudies method is called by passing a proper list of objects but on the browser i see only headers.
Please help me figuring out the issue.
I got the issue fixed using StackPanel.I am running in quirk mode so shifted to StackPanel instead of StackLayoutPanel which is supported only in standard mode.
I am trying to generate a chart based on user input. I am using JFree Charts in a Struts 2 framework. In the chart-generation Action class, I am unable to implement the ModelDriven concept; I am also unable to retrieve the parameter values from the HttpServletRequest Object. .
If I call the chart-generation action class with implementing ModelDriven or ServletRequestAware, it works fine but, it displays the chart on the next page. I need to generate the chart based on user input.
I was unsuccessful searching for information on JFree an Struts 2; any useful tutorial links would also be appreciated.
this is my struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd ">
<struts>
<package name="jfree" extends="jfreechart-default">
<action name="chartAction" class="com.kogent.action.ChartAction">
<result name="success" type="chart">
<param name="width">500</param>
<param name="height">300</param>
</result>
</action>
</package>
</struts>
and this is my Action class
package com.kogent.action;
import java.util.Random;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
public class ChartAction extends ActionSupport implements ModelDriven<FormBean>,Preparable{
private JFreeChart chart;
private FormBean bean;
#Override
public FormBean getModel() {
// TODO Auto-generated method stub
return bean;
}
#Override
public void prepare() throws Exception {
// TODO Auto-generated method stub
bean=new FormBean();
}
public String execute() throws Exception {
// chart creation logic...
System.out.print(bean.getCategory()+" "+bean.getChartType());
//if remove this above line my action runs fine but i require this vales from the user
XYSeries dataSeries = new XYSeries(new Integer(1));
for (int i = 0; i <= 100; i++) {
dataSeries.add(i, new Random().nextInt(50));
}
XYSeriesCollection xyDataSet = new XYSeriesCollection(dataSeries);
ValueAxis xAxis = new NumberAxis("Marks");
ValueAxis yAxis = new NumberAxis("Age");
chart =
new JFreeChart("Chart Title", JFreeChart.DEFAULT_TITLE_FONT,
new XYPlot(xyDataSet,xAxis, yAxis,
new StandardXYItemRenderer(StandardXYItemRenderer.LINES)),
false);
chart.setBackgroundPaint(java.awt.Color.white);
return super.SUCCESS;
}
public JFreeChart getChart() {
return chart;
}
}
Based on this jfree chart so many examples are there,
just i am giving those links check it out.
First:Implementing any jfree chart there is nothing required other than servlet request aware and servlet response aware, request is for taking request from user and response is for giving output to the user that's it. It's your wish to use 'ModelDriven' interface ( it gains the extra ability to transfer the form data into the object automatically).
just use this links.
Create chart and Display them dynamically in JSP.
Create area chart in JSP page using JFreeChart.
Creating Pie Charts with JFreeChart
Already discussion are there in stack overflow only
This is official site it will help full for you
I want to display a 20x20 grid of integer numbers in an AIR application. I am new to ActionScript and AIR, so I am not sure how I could go about doing this.
Because this isn't possible in a comment here a code example to elaborate it a little bit more:
Here is an example:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
private var ints:ArrayCollection;
protected function init(event:FlexEvent):void{
ints = new ArrayCollection();
for(var i:int = 0; i<199; i++){
ints.addItem(Math.round(Math.random()*10));
}
}
]]>
</fx:Script>
<s:DataGroup width="100%" height="100%"
dataProvider="{ints}"
itemRenderer="spark.skins.spark.DefaultItemRenderer">
<s:layout>
<s:TileLayout
requestedColumnCount="20"
requestedRowCount="20" />
</s:layout>
</s:DataGroup>
If you use Flex you could for example use a group with a tile layout.
With following attributes:
requestedColumnCount="20"
requestedRowCount="20"
You could place the 400 integers as Label or use a DataGroup with this layout...