I'm having some challenges with getting my Flex front-end form to pass its data into Coldfusion and subsequently SQL Server. Here is my code below:
MXML:
<?xml version="1.0" encoding="utf-8"?>
<s:Group 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="764" height="434"
width.State1="630" creationComplete="initApp()">
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
s|Form#form1 s|FormItem
{
skinClass: ClassReference("spark.skins.spark.FormItemSkin");
}
s|Form#form1 s|FormHeading
{
skinClass: ClassReference("spark.skins.spark.FormHeadingSkin");
}
s|Form#form1
{
skinClass: ClassReference("spark.skins.spark.FormSkin");
}
</fx:Style>
<fx:Script>
<![CDATA[
import assets.*;
import assets.comps.accountManagement.userLogin;
import assets.comps.accountManagement.userRegistration;
import model.*;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.events.ValidationResultEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.*;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
import vo.*;
//public var cfcResponse:String;
//this gets called when the application is done being created
//
[Bindable]
private function initApp():void{
//this calls the confirmCFC method in remoting.cfc
//cfc_ro.confirmCFC(); }
//Result Event Method maps RO call to Result Event
//public function loadConfirm(event:ResultEvent):void{
//this binds the cfcResponse var to the result of the RO call
//cfcResponse = event.result as String;
}
//Method submits registration information to the DB via the controller Registration.cfc
//Upon Successful registration, user receives a confirmation of their successful
registration.
protected function createUser():void
{
userRegistrationRO.userRegMethod(
fName.text,
lName.text,
uName.text,
password.text,
city.text,
state.name,
zip.text,
email.text,
DOB.name,
secQuestion1.name,
secQuestion2.name,
ans1.text,
ans2.text);
}
//Method initiated on the Reset button click and clears form fields
private function _resetForm():void
{
fName.text = "";
lName.text = "";
uName.text = "";
password.text = ""
city.text = "";
state.selectedIndex -1;
email.text = "";
confirm_email.text = "";
}
//Result event for registration
private function registrationResultEvent(event:ResultEvent):void{
}
//Fault handler for userRegMethod function
private function registrationFaultHandler(event:FaultEvent):void{
Alert.show("Your attempt to register was unsuccessful. Please try again. If problem
persists, contact Administrator")
}
//Registration RO Event Handler
private function regROHandler(event):void{
Alert.show("RO connection successful");
}
//Registration RO Fault Handler
private function regROFaultHandler(event:FaultEvent):void{
Alert.show("Error 100: Remote object call unsuccessful. Unable to submit data. Please
contact Administrator at support#blackiceems.com");
}
//variable references user registration popup
private var userRegForm:userRegistration;
//Registration Event Handler. Notifies user of successful registration by displaying a
confirmation message.
private function regHandler(event:Event):void
{ Alert.show("Registration Successful!");
PopUpManager.removePopUp(userRegForm); }
//This funtion calls user reg. form
private function showRegForm():void {
//This variable calls the Login Title Windows
//var userRegForm:userRegistration = new userRegistration as IFlexDisplayObject =
userRegForm = new userRegistration();
userRegForm.addEventListener(Event.CLOSE, closeHandler);
userRegForm.addEventListener("register", regHandler);
userRegForm.addEventListener("cancel", closeHandler);
PopUpManager.addPopUp(userRegForm, this, true);
PopUpManager.centerPopUp(userRegForm);
//userRegForm.setInitialFocus();
}
//Close Registration Event Handler
private function closeHandler(event):void
{Alert.show("You cancelled the login operation", "Login Cancelled");
PopUpManager.removePopUp(userRegForm);
}
]]>
</fx:Script>
</s:RemoteObject>-->
<!--End of Transitions Code Block-->
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<!--This remote object passes form data from the form into the CFC DAO. Data Validates on client and server side.-->
<!-- Defines the data model for the form. -->
<!--<fx:Model id="formInfo">
<formData>
<date>
<month>{monthInput.text}</month>
<day>{dayInput.text}</day>
<year>{yearInput.text}</year>
</date>
<name>
<firstName>{fNameInput.text}</firstName>
<lastName>{lNameInput.text}</lastName>
</name>
<phoneNum>{phoneInput.text}</phoneNum>
</formData>
</fx:Model>-->
<!-- Define the validators. -->
<mx:StringValidator id="fNameValidator"
required="true"
source="{fName}"
property="text"
minLength="3"
maxLength="10"
tooShortError="Your entry is too short to be a valid last name."
tooLongError="Your entry is too long to be a valid first name."/>
<mx:StringValidator id="lNameValidator"
required="true"
source="{lName}"
property="text"
minLength="2"
maxLength="12"
tooShortError="Your entry is too short to be a valid last name."
tooLongError="Your entry is too long for a last name."/>
<mx:StringValidator id="cityValidator"
required="true"
source="{city}"
property="text"
minLength="4"
maxLength="15"
tooShortError="Your city name is too short to be valid"/>
<mx:StringValidator id="stateValidator"
required="true"
source="{state}"
property="text"/>
<mx:ZipCodeValidator id="zipcodeValidator"
required="true"
source="{zip}"
property="text" />
<mx:StringValidator id="emailValidator"
required="true"
source="{email}"
property="text"
tooLongError="Your email address exceeded the maximum length allowed."
tooShortError="Your email address is too short to be a valid email address."/>
<mx:StringValidator id="confirm_emailValidator"
required="true"
source="{confirm_email}"
property="text"/>
<mx:StringValidator id="userNameValidator"
required="true"
source="{uName}"
property="text"
minLength="6"
maxLength="15"
tooShortError="Your username must be a minimum of 6 alphanumeric characters."
tooLongError="Your username is too long. Usernames must not exceed 15 alphanumberic characters."/>
</fx:Declarations>
<!--Form Layout Elements and text fields contained below-->
<s:TitleWindow height="100%" close="PopUpManager.removePopUp(this);" controlBarVisible="true"
title="New Member Registration"
width.p2="100%"
width.State1="100%">
<s:controlBarContent>
<s:Button label="Register"
click.p2="createUser();" enabled.p2="true"
click.State1="createUser();" enabled.State1="true"/>
<s:Button label="Reset"
click.State1="_resetForm();showRegForm();"/>
</s:controlBarContent>
<s:layout.State1>
<s:ConstraintLayout/>
</s:layout.State1>
<!--Form Starts Here-->
<s:Form id="RegForm" width="100%" height="90%" skinClass="spark.skins.spark.FormSkin">
<s:SkinnableContainer width="100%" height="350">
<s:FormItem id="f_Name" includeIn="State1" label="First Name">
<s:TextInput id="fName" width="100%" displayAsPassword="false" tabEnabled="true"
tabFocusEnabled="true" tabIndex="0"/>
</s:FormItem>
<s:FormItem id="l_Name" includeIn="State1" x="230" label="Last Name">
<s:TextInput id="lName" tabEnabled="true" tabFocusEnabled="true" tabIndex="1"/>
</s:FormItem>
<s:FormItem id="frm_city" includeIn="State1" x="0" y="53" label="City">
<s:TextInput id="city" tabIndex="2"/>
</s:FormItem>
<s:FormItem id="frm_zip" includeIn="State1" x="371" y="59" width="165"
label="Zip Code">
<s:TextInput id="zip" width="77"/>
</s:FormItem>
<s:FormItem id="frm_state" includeIn="State1" x="206" y="55" width="157" height="41"
label="State">
<s:DropDownList id="state" width="100" prompt="Select Date" selectedIndex="-1">
<s:dataProvider>
<s:ArrayList>
<fx:String> Alabama</fx:String>
<fx:String> Alaska</fx:String>
<fx:String> California</fx:String>
<fx:String> Colorado</fx:String>
<fx:String> Conneticut</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:DropDownList>
</s:FormItem>
<s:FormItem id="frm_email" includeIn="State1" x="0" y="100" width="214" label="Email">
<s:TextInput id="email" width="152"/>
</s:FormItem>
<s:FormItem id="frm_cfirm_email" includeIn="State1" x="257" y="100" width="279"
label="Confirm Email">
<s:TextInput id="confirm_email" width="152"/>
</s:FormItem>
<s:FormItem id="frm_username" includeIn="State1" x="1" y="142" width="213"
label="Username">
<s:TextInput id="uName"/>
</s:FormItem>
<s:FormItem id="frm_password" includeIn="State1" x="3" y="191" width="215"
label="Password">
<s:TextInput id="password" displayAsPassword="true"/>
</s:FormItem>
<s:Button x="0" y="326" label=">> Next"
x.p2="0" y.p2="328" width.p2="96" label.p2="<< Previous"
click.p2="currentState='State1'"
x.State1="0" y.State1="328" click.State1="currentState='p2';initApp();"/>
<s:FormItem includeIn="p2" x="1" y="10" width="644" label="Security Question 1:">
<s:DropDownList id="secQuestion1" width="409" mouseEnabled="false">
<s:dataProvider>
<s:ArrayList>
<fx:String> What was your high school mascot?</fx:String>
<fx:String> What is your mother's maiden Name?</fx:String>
<fx:String> What was your first car?</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:DropDownList>
</s:FormItem>
<s:FormItem includeIn="p2" x="1" y="108" width="644" label="Security Question 2:">
<s:DropDownList id="secQuestion2" width="409" mouseEnabled="false">
<s:dataProvider>
<s:ArrayList>
<fx:String> Who was your best friend growing up? </fx:String>
<fx:String> What city were you born in? </fx:String>
<fx:String> What was your first car?</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:DropDownList>
</s:FormItem>
<s:FormItem includeIn="p2" x="64" y="58" width="254" label="Answer 1">
<s:TextInput id="ans1" width="160"/>
</s:FormItem>
<s:FormItem includeIn="p2" x="359" y="59" width="286" label="Confirm Answer">
<s:TextInput width="160"/>
</s:FormItem>
<s:FormItem includeIn="p2" x="64" y="159" width="254" label="Answer 1">
<s:TextInput id="ans2" width="160"/>
</s:FormItem>
<s:FormItem includeIn="p2" x="359" y="160" width="286" label="Confirm Answer">
<s:TextInput width="160"/>
</s:FormItem>
<s:FormItem id="frm_DOB" includeIn="State1" x="257" y="153" label="D.O.B.">
<mx:DateChooser id="DOB" x="183" y="288" width="189" height="146"/>
</s:FormItem>
<!--This label displays value of cfcResponse variable when Front-end to CFC remote object call is successful-->
<!--<s:Label includeIn="State1" x="0" y="240" width="171" height="40" color="#F6F309"
text="{cfcResponse}"/>-->
</s:SkinnableContainer>
</s:Form>
</s:TitleWindow>
Coldfusion CFC:
<cffunction name="init" access="public" output="false" returntype="any">
<cfargument name="DSN" required="true" type="string" hint="datasource" />
<cfset variables.DSN = arguments.DSN />
<cfreturn this />
</cffunction>
<!---Flex app CFC Remoting test function--->
<cffunction name="confirmCFC" access="remote"
returntype="any"
description="tests the remote object communication between View the controller code" >
<cfreturn "Your Flex Remoting with this CFC is successful."/>
</cffunction>
<!---User Registraton--->
<!---Function pulls form values from flex form via Remote Object Call--->
<cffunction name="userRegMethod" access="remote" output="false" returntype="any">
<cfargument name="fName" type="string" >
<cfargument name="lName" type="string">
<cfargument name="uName" type="string" >
<cfargument name="password" type="string">
<cfargument name="city" type="string">
<cfargument name="state" type="any" default="CA">
<cfargument name="zip" type="string">
<cfargument name="email" type="string">
<cfargument name="dob" type="any" default="05/20/1982">
<cfargument name="secQuestion1" type="any" default="Mother's maiden name">
<cfargument name="secQuestion2" type="any" default="What's your high school mascot?">
<cfargument name="ans1" type="string" default="Maxine">
<cfargument name="ans2" type="string" default="Tigers">
<!---Query Checks for Existing User In DB--->
<cfquery name="qryUserExistence" datasource="blackiceDS">
select email,userName
from tblUserAccount
where email = <cfqueryparam value="#argument.email#" cfsqltype="cf_sql_varchar">
OR uName = <cfqueryparam value="#argument.uName#" cfsqltype="cf_sql_varchar">
</cfquery>
<!---If No User found by email, record count set to 0--->
<cfif qryUserExistence.RecordCount eq 0 >
<!---New User is then created in the table--->
<cfquery name="qryCreateUser" datasource="BlackIceDS">
INSERT INTO [dbo].tblUserAccount (fName,lName,uName,password, city, state, zip, email, dob,secQuestion1, secQuestion2, ans1, ans2)
VALUES (<cfqueryparam value="#fName#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#lName#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#uName#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#password#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#city#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#state#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#zip#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#email#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#dob#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#secQuestion1#" cfsqltype="cf_sqlvarchar">,
<cfqueryparam value="#secQuestion2#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#ans1#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#ans2#" cfsqltype="cf_sql_varchar">)
</cfquery>
<!---Upon creation of new user account, user is returned a verification welcome message--->
<cfelse>`enter code here`
<!---Otherwise if an existing account is discovered, user is informed of the
existing account and asked to select a different username and password--->
<cfreturn "An existing account was found with the selected username and/or
password. Please select a different email address."/>
</cfif>
</cffunction>
<!---End of User Registraton Functions--->
</cffunction>
My form has a date picker. How can I pass the selected date back to the CFC? When I try I get a Coldfusion error that the flex value is not of type date so I went to varchar as the value type and I still get an error. I'm trying to resolve this issue so my remote object call between Flex and CF verifies it works. I've included my preliminary code. Any thoughts would be appreciated.
If you are sending the date from flex to Coldfusion as a String then define dob as a String in Coldfusion:
<cfargument name="dob" type="string">
When you call the remote function, I see you are passing DOB.name. Convert DOB.selectedDate to String. You can use getDOBString(DOB.selectedDate)
You can define the function as below:
private function getDOBString(date:Date):String{
var df:DateFormatter = new DateFormatter();
df.formatString = "MM/DD/YYYY";
var dateString:String = df.format(date);
return dateString;
}
Related
Hi so I'm learning about razor, and razor pages; and I'm working on adding items to a simple db.
I noticed something odd with the input in my form when I try to enter a Quantity (should be a int) it throws an error when I press 1 or any number; and says it should be string/Array/collection? Whats that about??
code excerpt from Products.razor:
#if (products != null) // Insert form
{
<EditForm Model="#product" OnValidSubmit="#HandleAdd">
<DataAnnotationsValidator />
<ValidationSummary />
<InputText placeholder="Product Name" id="ProductName" #bind-Value="#product.ProductName" />
<br />
<InputText placeholder="Unit of Measurement" id="Unit" #bind-Value="#product.Unit" />
<br />
<InputNumber min="1" step="1" placeholder="Quantity" id="Quantity" #bind-Value="#product.Quantity" />
<br />
<InputNumber min="0.01" step="0.01" placeholder="Unit Price" id="UnitPrice" #bind-Value="#product.UnitPrice" />
<br />
<InputText placeholder="Category" id="Category" #bind-Value="#product.Category" />
<br />
<button type="submit">Submit</button>
</EditForm>
Wierd error in colsole:
I did notice someone had an idea on a un-related question:
Blazor EditForm adding InputNumber fields
But I treid that and its still not working; and additionally with this form code; now the little green border box indicating valid input doesnt light up.
Any help would be appreciated :D
Made a mistake in the constrution of my Product class applying a [MaxLength] attribute to my Quantity.
Removed it, add new migrations, and now it works :)
Having an issue getting the Record Ids of the selected record in Lightning Datatable.
Here is my controller
<!-- attributes -->
<aura:attribute name="dataArr" type="String[]"/>
<aura:attribute name="data" type="Object"/>
<aura:attribute name="columnsStr" type="String"/>
<aura:attribute name="columns" type="List"/>
<aura:attribute name="maxRowSelection" type="Integer" default="1"/>
<aura:attribute name="numOfRowsSelected" type="Integer" default="0"/>
<aura:attribute name="key" type="String" default="Id"/>
<aura:attribute name="recordId" type="String" />
<aura:attribute name="recordIds" type="String" />
<!-- handlers-->
<aura:handler name="init" value="{!this }" action="{! c.doInit }"/>
<div style="height: 300px">
<lightning:datatable keyField="{!v.key}"
data="{! v.data }"
columns="{! v.columns }"
maxRowSelection="{! v.maxRowSelection }"
onrowselection="{! c.setRecordId }"
/>
</div>
and here is my setRecordId function
setRecordId : function(component, event, helper){
var selectedRows = event.getParam('selectedRows');
var key = component.get('v.key');
var recIds = '';
console.log(selectedRows);
if(selectedRows){
if(selectedRows.length === 1){
console.log(selectedRows.id)
console.log(selectedRows[key])
console.log(selectedRows[0][key])
component.set('v.recordId', selectedRows[0][key]);
}
else{
for(let i = 0; i < selectedRows.length; i++){
recIds += selectedRows[i][key] + ',';
}
component.set('v.recordIds', recIds);
component.set('v.numOfRowsSelected', selectedRows.length);
}
}
},
Var selectedRows returns the correct selected row as an object within an array but i can't seem to find the correct syntax to access that records ID for some reason. Let me know if any additional information is needed here.
appreciate the help
You will have to iterate over the selected rows in a for-loop and you can then get the id references -
Something like -
for(var i=0; i<selectedRows.length; i++){
//This will give you the entire data for the row
console.log(selectedRows[i]);
//You can now fetch its Id as well as other parameters
...
}
When the form is initially loaded the multicombo on the form correctly reflects the data that is set up.
However, if I attempt to update the information at runtime, the list of options in the multicombo aren't updated when the form is displayed.
I have them successfully defined as form options, they have a simple 'text' only store. However, I can't seem to find the correct set of properties and method to actually update the multicombo from the C# code as needed.
I've noticed this as well. You can set the Ext.net.ListItems on page-load but they are fickle when it comes to setting them dynamically in code-behind. I now always use a Ext.net.Store with any Multicombo or ComboBox that needs to dynamically change.
You can use the Handler events on Focus or BeforeSelect to reload the list.
<ext:ComboBox ID="ComboBoxTransferGroupMembers" runat="server" FieldLabel="Transfer To" EmptyText="Group Members" LabelAlign="Top" DisplayField="Name" ValueField="Id" MarginSpec="0 0 5">
<Listeners>
<Focus Handler="#{ComboBoxTransferGroupMembers}.store.reload()" />
</Listeners>
<Store>
<ext:Store runat="server" OnReadData="StoreTransferGroupMember_ReadData" ID="StoreXferGroup">
<Model>
<ext:Model IDProperty="Id" runat="server">
<Fields>
<ext:ModelField Name="Name" />
<ext:ModelField Name="Id" />
</Fields>
</ext:Model>
</Model>
<Parameters>
<ext:StoreParameter Mode="Raw" Name="Group" Value="#{ComboBoxTransferGroup}.getValue()" />
</Parameters>
</ext:Store>
</Store>
<DirectEvents>
<Select OnEvent="ComboBoxTransferGroupMembers_Select">
<ExtraParams>
<ext:Parameter Mode="Raw" Name="Group" Value="#{ComboBoxTransferGroup}.getValue()" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:ComboBox>
I'm developing an application in Coldfusion and AngularJS. I'm use AngularJS 1 and CF11.
A user has to be logged into the application. The user id is saved in the CF session.
In myAngularJS service I implemented Factories like that:
app.factory('ContactService', function($http){
var factory={};
factory.getContact=function(id){
return $http.post('http://myapp/contacts.cfc?method=getContacts&subsString=' + id);
};
return factory;
})
Here my component contacts.cfc
<cfcomponent displayname="Contacts" hint="Webservice for contacts app">
<cffunction name="getContacts" access="remote" returnformat="JSON" output="no">
<cfargument name="subsString" required="no" type="String" />
<cfset ret = arrayNew(1) />
<cftry>
<cfinclude template="cfc/person/qry/qry_Search.cfm" />
<cfloop from="1" to="#qryFastSearch.recordcount#" index="i">
<cfset searchVO = structNew() />
<cfset searchVO['ID']= #qryFastSearch.ID[i]# />
<cfset searchVO['PERSON']= #qryFastSearch.personName[i]# />
<cfset searchVO['COMPANY']= #qryFastSearch.COMPANY[i]# />
<cfset ret[i] = searchVO />
</cfloop>
<cfcatch type="any">
<cfset returnVO = structNew() />
<cfset returnVO.ERROR = true />
<cfset returnVO.MESSAGE = cfcatch.Message />
<cfset ret[1] = returnVO />
</cfcatch>
</cftry>
<cfreturn SerializeJSON(ret)>
</cffunction>
</cfcomponent>
When the system execute the controller, the factory is executed and the results appear. We can see in the console of the browser the url executed.
For example: http://myapp/contacts.cfc?method=getContacts&subsString=test
I would like to avoid a person to execute a query (thanks to this kind of url) if she is not connected into the application.
Is it equally possible to hide the url in the browser ?
What is the best way in order to do that ?
Many thanks in advance for your help.
To add to Dan's comment:
Ensure the user is logged in.
Check the value of CGI.REQUEST_METHOD. If it's not POST, then reject the request.
If you have roles & privileges, verify the user should access that URL.
Validate search parameters as best you can.
Since you're using $http.post(), you shouldn't be passing the subString in the query string. It should be part of the posted data to avoid browser caching and entries in the server logs that possibly shouldn't be there.
You state, "The user id is saved in the CF session". Pass it as an argument to your function.
<cffunction name="getContacts" access="remote" returnformat="JSON" output="no">
<cfargument name="subsString" required="no" type="String" />
<cfargument name="userId" required="yes" type="String" />
Then check for it.
<cfif StructKeyExists(session, "userId")
and session.userId is arguments.userId>
rest of function
<cfelse>
whatever you want goes here.
the main concern is my query is running smoothly in SQL and also in table dataset query preview. i mean in table dataset query data preview it's displaying 2 records from my database table.
please find the screen shot.
also find Jrxml file.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1">
<queryString>
<![CDATA[select lname, fname from test1
order by fname]]>
</queryString>
<field name="lname" class="java.lang.String"/>
<field name="fname" class="java.lang.String"/>
</subDataset>
<subDataset name="New Dataset 1">
<queryString language="SQL">
<![CDATA[select lname, fname from test1
order by fname]]>
</queryString>
<field name="lname" class="java.lang.String"/>
<field name="fname" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[select lname, fname from test1
order by fname]]>
</queryString>
<field name="lname" class="java.lang.String"/>
<field name="fname" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch">
<staticText>
<reportElement x="100" y="41" width="102" height="20"/>
<textElement/>
<text><![CDATA[lname]]></text>
</staticText>
<staticText>
<reportElement x="202" y="41" width="147" height="20"/>
<textElement/>
<text><![CDATA[fname]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement key="table" style="table" x="100" y="0" width="360" height="86"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 1">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{lname}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{fname}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
but the output in pdf report is only 1 record which is last 1.
This is happening to me when using a JRBeanCollectionDataSource. I know for a fact that all the data is there but the table tool keeps missing the first row.
It looks like the main report executes a ".next()" on the collection or something then the subreport (a.k.a table) keeps on going with the rest of the data
Anyway, I solved it passing $P{REPORT_DATA_SOURCE}.cloneDataSource() as the dataSource expression of the table. Then it looks like the table starts with a brand new datasource and can iterate through all the items, and so, it works.
I don't know what datasource you are using but you have to figure out a way to move the cursor to the beginning of your data before using the subreport.
So, summing up, I did this in my jrxml file:
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.cloneDataSource()]]></dataSourceExpression>
but Only because I am using a JRBeanCollectionDataSource
Exactly the same problem as kawda and exactly the same behavior than user1972796 : multiple tables instead of one, but correct number of rows in one table.
The problem seams to appear in cases where the master report doesn't iterate over anything and the subreport has been put into the Details Band and references the master data source via $P{REPORT_DATA_SOURCE}
The explanation (and solution) seams to be this one: http://community.jaspersoft.com/wiki/why-first-record-missing-my-subreport
Maybe you should use <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>instead <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>