[flexcoders] Re: Need help dynamically modifying text displayed based on DB return

2012-02-07 Thread hermeszfineart


The solution was actually simple but took a great deal of digging.

I created a protected function as follows:


protected function onLabelCreationComplete():void
{   
if ( imageStatus == 'Available' ){
artPrice.setStyle(color, 0xC39F70);
artPrice.text = imagePrice;
}
else if ( imageStatus == 'Sold' ) {
artPrice.setStyle(color, 0xED1F04);
artPrice.text = imageStatus;
}
else {
artPrice.setStyle(color, 0xC39F70);
artPrice.text = imageStatus;
}
}

Then I called the function from the Label control:

s:Label id=artPrice width=120 textAlign=left
 fontFamily=Times New Roman fontSize=18 
 creationComplete=onLabelCreationComplete()/

The setStyle operator resolved the issue completely.

I used your states idea but implemented id using conditional statements.

Thanks for the reply this was helpful.

John


--- In flexcoders@yahoogroups.com, Haykel BEN JEMIA haykelbj@... wrote:

 I think the best way is to use states. Define the different states for your
 component, e.g.
 
 s:states
 s:State name=available /
 s:State name=sold /
 s:State name=other /
 /s:states
 
 You have now to track changes to win.status and set the current state
 accordingly, e.g. by listening to the property change event on win:
 
 protected function win_propertyChangeHandler(event:PropertyChangeEvent):void
 {
 switch (event.property)
 {
 case status:
 imageStatus = event.newValue;
 switch (event.newValue)
 {
 case Available:
 currentState = available;
 break;
 case Sold:
 currentState = sold;
 break;
 default:
 currentState = other;
 break;
 }
 break;
 }
 }
 
 and finally set the properties of the artPrice text based on the current
 state:
 
 s:RichText id=artPrice width=120 color=#00
 color.sold=#C39F70 fontFamily=Times New Roman fontSize=18
 text={imageStatus} text.available={imagePrice} /
 
 I hope this helps.
 
 Haykel Ben Jemia
 
 Allmas
 Web  Mobile Development
 http://www.allmas-tn.com
 
 
 
 
 On 30 January 2012 14:55, hermeszfineart hermeszfineart@... wrote:
 
  **
 
 
  Part of the functionality in the gallery app ia am working on for my wife
  is a popup window that displays information about the specific painting or
  drawing.
 
  I am trying to figure out how to do the following based on the value
  returned from the DB for the imageStatus field:
  1) Change the text displayed for the Price to the {imageStatus)if that
  value is anything other than Available.
  2) Change the color of the above text to RED if the {imageStatus) == Sold.
 
 
 
  fx:Script
  ![CDATA[
 
  ... //cut for brevity
 
  [*Bindable*] *public* *var* imageTitle:String = *{win.title}*;
 
  [*Bindable*] *public* *var* imageStatus:String = *{win.status}*;
 
  [*Bindable*] *public* *var* imagePrice:String = *{win.price}*;
 
  [
  *Bindable*] *public* *var* displayPrice:String ;
 
 
 
  ... // cut for brevity
 
  ]]
  /fx:Script
 
  s:Group
 
  s:layout
 
  s:VerticalLayout/
 
  /s:layout
 
  s:RichText id=style x=13 y=14 width=120 color=#C39F70
  fontFamily=Times New Roman fontSize=18 text={imageStyle}/
 
  s:RichText width=120 color=#C39F70 fontFamily=Times New Roman
  fontSize=18 text={imageMedium}/
 
  s:RichText id=dimensions width=112 color=#C39F70 fontFamily=Times
  New Roman fontSize=18 text={imageHeight} x {imageWidth}/
 
  s:RichText id=artPrice width=120 color=#C39F70 fontFamily=Times
  New Roman fontSize=18 text={imagePrice} / !-- Currently displaying
  the art's price --
 
  /s:Group
 
  I have tried several things with public functions, getters/setters, but
  have gotten no where.
 
  Could someone kindly point me in the right direction?
 
  Thanks,
 
  John
   
 





[flexcoders] Re: Problems creating/updating DB record with selection from DropDownList

2012-02-06 Thread hermeszfineart


Thanks Scott.

I managed to get things talking ... somewhat before your reply came in. The 
data provider showed the proper data. I did a bit of digging and came up with 
the new code shown below.  Unfortunately with the new code, if I only need to 
update a single field in the DB I must click every DDL and select the value 
otherwise the other fields receive NULL values.
Any suggestions?

Here is the newest code:

fx:Script
![CDATA[
[Bindable]
public var _selectedStatus:String;
[Bindable]
public var _selectedCategory:String;
[Bindable]
public var _selectedStyle:String;

private function statusChanged(e:IndexChangeEvent):void {
if ( _selectedStatus == null ) {
_selectedStatus = originals.status;
}
_selectedStatus = statusDDL.selectedItem.status;
}

protected function categoryChanged(e:IndexChangeEvent):void {
if ( _selectedCategory == null ) {
_selectedCategory = originals.category;
}
_selectedCategory = categoryDDL.selectedItem.category;
}

protected function stylesChanged(event:IndexChangeEvent):void {
if ( _selectedStyle == null ) {
_selectedStyle = originals.style;
}
_selectedStyle = styleDDL.selectedItem.style;
}

// This function use to add or update records in the database
protected function button_clickHandler(event:MouseEvent):void {
originals.inventoryno = inventorynoTextInput.text;
originals.title = titleTextInput.text;
originals.price = priceTextInput.text;
originals.status = _selectedStatus;
originals.category = _selectedCategory;
originals.style = _selectedStyle;
originals.edition = _selectedEdition;
originals.subject = _selectedSubject;
originals.height = _selectedHeight;
originals.width = _selectedWidth;
originals.medium = _selectedMedium;
originals.imagename = imagenameTextInput.text;
originals.description = descriptionTextInput.text;
originals.copyrightdate = copyrightdateDateField.selectedDate;
if (originals.originalid==0){
createOriginalResult.token = artServices.createOriginal(originals);
}
else{
updateOriginalResult.token = artServices.updateOriginal(originals);
}
}   

]]

/fx:Script

// The declarations remain the same as before for each of the lists

// The FormItems DropDownList/ changed as well. one example below:

/s:FormItem
s:FormItem label=Status styleName=formLabel
s:DropDownList id=statusDDL
labelField=status styleName=formContent
skinClass=CustomSkins.CustomDropDownListSkin
dataProvider={statusList}
prompt={originals.status}
change=statusChanged(event)
creationComplete=statusDDL_creationCompleteHandler(event)
symbolColor=#FF borderColor=#c3c3c3
width=157 color=#00/
/s:FormItem


--- In flexcoders@yahoogroups.com, Scott Fanetti scott.fanetti@... wrote:

 It looks like you are setting the status on the change in the drop down list 
 but not casting it. Is that your issue? The change handler does not seem 
 attached - what is triggering it?  When you debug it - what are the contents 
 of the drop down list data provider?  
 
 Sent from my iPhone
 




[flexcoders] Re: Problems creating/updating DB record with selection from DropDownList

2012-02-06 Thread hermeszfineart
I resolved part of the issue. However, as with many things one resolution 
reveals aditional issues. Creating a new record works fine. Updating existing 
records requires making selections for all DropDownLists (DDLs) even if the 
user is only correcting data in a TextInput box. Otherwise, the fields get 
populated with NULL values.
What did I miss?

The new code is a follows:

fx:Script
![CDATA[
// Define the variables used within the DDLs
[Bindable]
public var _selectedStatus:String;
[Bindable]
public var _selectedCategory:String;
[Bindable]
public var _selectedStyle:String;

// Functions to facilatate selection changes
private function statusChanged(e:IndexChangeEvent):void
{
if ( _selectedStatus == null ) {
_selectedStatus = originals.status;
}
_selectedStatus = statusDDL.selectedItem.status;
}

protected function categoryChanged(e:IndexChangeEvent):void
{
if ( _selectedCategory == null ) {
_selectedCategory = originals.category;
}
_selectedCategory = categoryDDL.selectedItem.category;
}

protected function stylesChanged(event:IndexChangeEvent):void
{
if ( _selectedStyle == null ) {
_selectedStyle = originals.style;
}
_selectedStyle = styleDDL.selectedItem.style;
}   

]]
/fx:Script

/s:FormItem
s:FormItem label=Edition styleName=formLabel
s:DropDownList id=editionDDL width=157 
borderColor=#c3c3c3
change=editionChanged(event) color=#00

creationComplete=editionDDL_creationCompleteHandler(event)
labelField=edition 
prompt={originals.edition}
skinClass=CustomSkins.CustomDropDownListSkin
styleName=formContent symbolColor=#FF
dataProvider={editionList}/
/s:FormItem

--- In flexcoders@yahoogroups.com, Scott Fanetti scott.fanetti@... wrote:

 It looks like you are setting the status on the change in the drop down list 
 but not casting it. Is that your issue? The change handler does not seem 
 attached - what is triggering it?  When you debug it - what are the contents 
 of the drop down list data provider?  
 
 Sent from my iPhone
 
 On Feb 5, 2012, at 8:31 AM, hermeszfineart hermeszfineart@... wrote:
 
  I have been trying to migrate certain form fields from s:TextInput/ to 
  s:DropDownList/ where the DB columns have foreign keys to different 
  tables (i.e. Status, Categories, Dimensions) so the user does not need to 
  type the values. When I attempt to update the DB record it populates the 
  field with [object Status]. This implementation is primarily for the back 
  office management of the application but some of this type of 
  functionallity will be used to drive the front end as well in the future.
  
  I know I must be missing something very simple so any help is appreciated.
  
  Here is the applicable code:
  
  fx:Script
  
  ![CDATA[
  
  import mx.binding.utils.BindingUtils;
  
  import mx.collections.IList;
  
  importmx.collections.errors.ItemPendingError;
  
  import mx.controls.Alert;
  
  import mx.events.FlexEvent;
  
  import mx.rpc.AsyncResponder;
  
  import mx.rpc.AsyncToken;
  
  import mx.rpc.Fault;
  
  import mx.rpc.events.FaultEvent;
  
  import mx.rpc.events.ResultEvent;
  
  import spark.events.GridItemEditorEvent;
  
  import spark.events.GridSelectionEvent;
  
  import spark.events.IndexChangeEvent;
  
  import valueObjects.Categories;
  
  import valueObjects.Dimensions;
  
  import valueObjects.Editions;
  
  import valueObjects.Mediums;
  
  import valueObjects.Status;
  
  import valueObjects.Styles;
  
  import valueObjects.Subjects;
  
  [Bindable] private var _selectedStatus:String = Available ;
  
  private function statusChanged(event:IndexChangeEvent):void{
  
  if (event.newIndex == -1) return;
  
  _selectedStatus = statusList.getItemAt(event.newIndex) as String;
  
  }
  
  protected function button_clickHandler(event:MouseEvent):void{
  
  originals.inventoryno = inventorynoTextInput.text;
  
  originals.title = titleTextInput.text;
  
  originals.price = priceTextInput.text;
  
  originals.status = _selectedStatus; // Original version -- originals.status 
  = statusTextInput.text:
  
  originals.category = categoryTextInput.text

[flexcoders] Problems creating/updating DB record with selection from DropDownList

2012-02-05 Thread hermeszfineart
I have been trying to migrate certain form fields from s:TextInput/ to 
s:DropDownList/ where the DB columns have foreign keys to different tables 
(i.e. Status, Categories, Dimensions) so the user does not need to type the 
values. When I attempt to update the DB record it populates the field with 
[object Status]. This implementation is primarily for the back office 
management of the application but some of this type of functionallity will be 
used to drive the front end as well in the future.

I know I must be missing something very simple so any help is appreciated.

Here is the applicable code:

fx:Script

![CDATA[

import mx.binding.utils.BindingUtils;

import mx.collections.IList;

importmx.collections.errors.ItemPendingError;

import mx.controls.Alert;

import mx.events.FlexEvent;

import mx.rpc.AsyncResponder;

import mx.rpc.AsyncToken;

import mx.rpc.Fault;

import mx.rpc.events.FaultEvent;

import mx.rpc.events.ResultEvent;


import spark.events.GridItemEditorEvent;

import spark.events.GridSelectionEvent;

import spark.events.IndexChangeEvent;


import valueObjects.Categories;

import valueObjects.Dimensions;

import valueObjects.Editions;

import valueObjects.Mediums;

import valueObjects.Status;

import valueObjects.Styles;

import valueObjects.Subjects;

[Bindable] private var _selectedStatus:String = Available ;


private function statusChanged(event:IndexChangeEvent):void{

if (event.newIndex == -1) return;

_selectedStatus = statusList.getItemAt(event.newIndex) as String;

}

protected function button_clickHandler(event:MouseEvent):void{

originals.inventoryno = inventorynoTextInput.text;

originals.title = titleTextInput.text;

originals.price = priceTextInput.text;

originals.status = _selectedStatus;   // Original version -- originals.status = 
statusTextInput.text:

originals.category = categoryTextInput.text;

// Output omitted

if (originals.originalid==0){

createOriginalResult.token = artServices.createOriginal(originals);

}

else{

updateOriginalResult.token = artServices.updateOriginal(originals);

}

}

]]

/fx:Script

fx:Declarations

s:AsyncListView id=statusList 
list={getAllArtStatusResult.lastResult}/ !-- DataProvider --

/fx:Declarations

!-- output omitted for brevity --

s:FormItem label=Status styleName=formLabel

s:TextInput id=statusTextInput styleName=formContent 
text={originals.status}/ !-- this is one of the fields I am trying to 
replace --

s:DropDownList id=dropDownStatusList

labelField=status styleName=formContent 
skinClass=CustomSkins.CustomDropDownListSkin dataProvider={statusList}  
prompt={originals.status}

  change={_selectedStatus = dropDownStatusList.selectedItem} 
creationComplete=dropDownList_creationCompleteHandler(event)

  symbolColor=#FF borderColor=#c3c3c3   width=157 color=#00

/s:DropDownList

/s:FormItem




[flexcoders] Re: Build Release (generated on Windows) returns NULL query values

2012-01-30 Thread hermeszfineart
Issue resolved.

The problem was, in part, with my MySql setup and the ip addresses I had set it 
up to listen to for this particular app.

Secondary to this was in the CFC used to connect to the CF Data Source 
(username  password for the DB).



[flexcoders] Need help dynamically modifying text displayed based on DB return

2012-01-30 Thread hermeszfineart

Part of the functionality in the gallery app ia am working on for my
wife is a popup window that displays information about the specific
painting or drawing.

I am trying to figure out how to do the following based on the value
returned from the DB for the imageStatus field:
1) Change the text displayed for the Price to the {imageStatus)if that
value is anything other than Available.
2) Change the color of the above text to RED if the {imageStatus) ==
Sold.



fx:Script![CDATA[

... //cut for brevity

[Bindable] public var imageTitle:String = {win.title};

[Bindable] public var imageStatus:String = {win.status};

[Bindable] public var imagePrice:String = {win.price};

[Bindable] public var displayPrice:String ;



... // cut for brevity

]] /fx:Script

s:Group

s:layout

s:VerticalLayout/

/s:layout

s:RichText id=style x=13 y=14 width=120 color=#C39F70
fontFamily=Times New Roman fontSize=18 text={imageStyle}/

s:RichText width=120 color=#C39F70 fontFamily=Times New Roman
fontSize=18 text={imageMedium}/

s:RichText id=dimensions width=112 color=#C39F70
fontFamily=Times New Roman fontSize=18 text={imageHeight} x
{imageWidth}/

s:RichText id=artPrice width=120 color=#C39F70 fontFamily=Times
New Roman fontSize=18 text={imagePrice} / !-- Currently
displaying the art's price --

/s:Group

I have tried several things with public functions, getters/setters, but
have gotten no where.

Could someone kindly point me in the right direction?

Thanks,

John



[flexcoders] Build Release (generated on Windows) returns NULL query values

2012-01-27 Thread hermeszfineart
when migrated to Linux Production server.

Dev environment: Win 7 Pro, CF9/Apache/MySQL, AI/FC/FB4.5
Production Env:  LAMP/CF9

I am a beginner in Flex and I have been working on developing a new Web Site 
for my wife's art.

Beginning with the backend (database functionallity) and then the frontend 
goodies. The site, as it is now, works fine on my Dev machine but when I move 
the app to the linux server (Ubuntu 10.?) database queries return NULL values.

http://www.elisabetahermann.com/Main.html

Go to the Gallery link to see. also if you mouseover any of the missing images 
and click I should have a larger view of the selected art. note the null X 
null next to the dimensions Label.

Originally, the CFCs were in the [root]/CFC directory and this threw an error 
Cannot find CFC ...
I moved them to root/elisabetahermann/CFC and the error went away but no joy on 
the query results.

Any suggestions?