Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Displaying the Header Label and list of records!!

I added 61 rows and wasn't able to scroll horizontally using the trackpad, but could scroll using the touch screen.  

 

On 7.0, I was able to scroll using both the trackpad and touch screen.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 10
Registered: ‎09-26-2011
My Device: BB9800-Developer
My Carrier: Developer

Re: Displaying the Header Label and list of records!!

But it doesn't work for meSmiley Sad  i am clueless as where my mistake is....

 

All my testing were done on the BlackBerry Simulators and not on the Real devices..

 

In BB Simulator 9800, there is a message saying we can use the right mouse button to test the Touch Screen movements...so i tested with that, but still no luck....

 

So i downloaded BB Simulator 9850 which is using Version 7.0 and ran my project with that also...but still i am not able to scroll horizontally...

 

Should i add any touchEvent code to scroll horizontally? or what am i missing  and i should get that working somehow..help me plz...

Contributor
Posts: 10
Registered: ‎09-26-2011
My Device: BB9800-Developer
My Carrier: Developer

Re: Displaying the Header Label and list of records!!

Also, i commented the code

//super(Manager.NO_VERTICAL_SCROLL|Manager.HORIZONTAL_SCROLL|Manager.USE_ALL_WIDTH);

 

and used a new VerticalFieldManager like below,

VerticalFieldManager vfm=

new VerticalFieldManager(Manager.NO_VERTICAL_SCROLLBAR|Manager.HORIZONTAL_SCROLL|Manager.USE_ALL_WIDTH);

 

and added the tableview to this vfm and inturn added the vfm to the screen...

 

Here i am able to scroll horizontally but when i scroll vertically i am not able to view the dockedHeader added...This is the problem with the creation of new vfm...

Contributor
Posts: 10
Registered: ‎09-26-2011
My Device: BB9800-Developer
My Carrier: Developer

Re: Displaying the Header Label and list of records!!

Could somebody help me on this?

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Displaying the Header Label and list of records!!

Can you post a larger code sample that triggers this?  As I mentioned I was unable to reproduce this.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 10
Registered: ‎09-26-2011
My Device: BB9800-Developer
My Carrier: Developer

Re: Displaying the Header Label and list of records!!

Here is the code with VerticalFieldManager added seperately:

 

package custom.sap.mbo;

import java.util.Vector;
import TutSOSAPRFC.SalesOrder;
import TutSOSAPRFC.SalesOrderItem;

import com.sybase.collections.ObjectList;
import net.rim.device.api.command.Command;
import net.rim.device.api.command.CommandHandler;
import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Adjustment;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.table.DataTemplate;
import net.rim.device.api.ui.component.table.DataView;
import net.rim.device.api.ui.component.table.TableController;
import net.rim.device.api.ui.component.table.TableModel;
import net.rim.device.api.ui.component.table.TableView;
import net.rim.device.api.ui.component.table.TemplateColumnProperties;
import net.rim.device.api.ui.component.table.TemplateRowProperties;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;
import net.rim.device.api.ui.toolbar.ToolbarButtonField;
import net.rim.device.api.ui.toolbar.ToolbarManager;
import net.rim.device.api.ui.toolbar.ToolbarSpacer;
import net.rim.device.api.util.StringProvider;

public class SOTableView extends MainScreen{

	TableView theView;
	TableModel theModel;
	TableController theController;
	int noOfRows=1;
	int noOfColumns=6;
	Vector salesOrders=new Vector();
	SalesOrderApp app;
	Font labelFont,headerFont;
	public SOTableView(Vector _salesOrders,SalesOrderApp _app)
	{
		//super(Manager.NO_VERTICAL_SCROLL|Manager.HORIZONTAL_SCROLL|Manager.USE_ALL_WIDTH);
		
		VerticalFieldManager vfm=new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL|Manager.HORIZONTAL_SCROLL|Manager.USE_ALL_WIDTH);
		//Manager mgr=getMainManager();
		Background bg=BackgroundFactory.createSolidBackground(Color.SNOW);
		
		app=_app;
		salesOrders=_salesOrders;
		
		FontFamily fontFamily;
		try 
		{
			fontFamily = FontFamily.forName("Monotype Corsiva");
			labelFont=fontFamily.getFont(Font.ITALIC|Font.BOLD, 30);
			headerFont=Font.getDefault().derive(Font.BOLD,20);
		} 
		catch (ClassNotFoundException e) {
			
			e.printStackTrace();
		}
		
		LabelField noOfSO=new LabelField("Total Sales Orders : "+salesOrders.size(),LabelField.FIELD_LEFT|LabelField.USE_ALL_WIDTH);
		noOfSO.setFont(labelFont);
		theModel = new TableModel();
		theView= new TableView(theModel);
		theController = new TableController(theModel, theView, TableController.ROW_FOCUS);
		theController.setCommand(new CommandHandler() {
			
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				displaySOInfoScreen(theView.getRowNumberWithFocus());
			}
		}, null, theController);
		theView.setController(theController);
		theView.setDataTemplateFocus(BackgroundFactory.createLinearGradientBackground(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY));
		LabelField header=new LabelField("Sales Doc            Cus #        Type     Org.     Dis.Channel         NetValue",LabelField.USE_ALL_WIDTH|LabelField.FOCUSABLE);
		header.setFont(headerFont);
		theView.addDockedHeader(header);
		
		TestDataTemplate theTemplate = new TestDataTemplate(theView, noOfRows,noOfColumns);
		for(int i=0;i<noOfColumns;i++)
		{
			theTemplate.createRegion(new XYRect(i,0,1,1));
		}

		theTemplate.setColumnProperties(0, new TemplateColumnProperties(140));
		theTemplate.setColumnProperties(1, new TemplateColumnProperties(140));
		theTemplate.setColumnProperties(2, new TemplateColumnProperties(60));
		theTemplate.setColumnProperties(3, new TemplateColumnProperties(120));
		theTemplate.setColumnProperties(4, new TemplateColumnProperties(90));
		theTemplate.setColumnProperties(5, new TemplateColumnProperties(160));
				
		theTemplate.setRowProperties(0, new TemplateRowProperties(40));
		
		theTemplate.useFixedHeight(true);
		theView.setDataTemplate(theTemplate);

		for(int i=0;i<salesOrders.size();i++)
		{
			SalesOrder so= new SalesOrder();
			so=(SalesOrder) salesOrders.elementAt(i);
			theModel.addRow(new String[]{so.getVBELN(),so.getKUNNR(),so.getAUART(),so.getVKORG(),so.getVTWEG(),so.getNETWR()});
		}
		
		ToolbarManager toolbar=new ToolbarManager(FIELD_HCENTER);
		setToolbar(toolbar);
		ToolbarButtonField detailsButton =new ToolbarButtonField(new StringProvider("Details"));
		detailsButton.setCommand(new Command(new CommandHandler() {
			
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				displaySOInfoScreen(theView.getRowNumberWithFocus());
			}
		}));
		
		ToolbarButtonField restrictedSearch =new ToolbarButtonField(new StringProvider("Search"));
		restrictedSearch.setCommand(new Command(new CommandHandler() {
			
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				SalesOrderUsingCustomerNo cusNo=new SalesOrderUsingCustomerNo(app);
		    	app.pushScreen(cusNo);
			}
		}));
		
		ToolbarButtonField viewAllButton =new ToolbarButtonField(new StringProvider("View All"));
		viewAllButton.setCommand(new Command(new CommandHandler() {
			
			public void execute(ReadOnlyCommandMetadata metadata, Object context) {
				SalesOrderLoginScreen soLS=new SalesOrderLoginScreen(app);
				SOTableView cusNo=new SOTableView(soLS.getAllSalesOrders(),app);
		    	app.pushScreen(cusNo);
			}
		}));
		toolbar.add(detailsButton);
		toolbar.add(restrictedSearch);
		toolbar.add(viewAllButton);
		vfm.add(noOfSO);
		vfm.add(theView);
		this.add(vfm);
		//mgr.setBackground(bg);
	}

	public void displaySOInfoScreen(int selectedIndex)
	{	
		SalesOrder selectedSO = new SalesOrder();
		selectedSO=(SalesOrder) salesOrders.elementAt(selectedIndex);
		Vector selectedSOItems=getSalesOrderItems(selectedSO.getVBELN());
		SalesOrderInfoScreen soInfo= new SalesOrderInfoScreen(selectedSO,selectedSOItems);
		app.pushScreen(soInfo);
	}
	public Vector getSalesOrderItems(String salesDocumentNumber)
	{
	  	ObjectList SalesOrderItems = SalesOrderItem.findBySalesDocumentNumber(salesDocumentNumber);
	   	Vector soVector= new Vector(SalesOrderItems.size());
	   	int soSize = SalesOrderItems.count();
	   	for(int i=0;i<soSize;i++)
	   	{
	   		soVector.addElement(SalesOrderItems.elementAt(i));
	   	}
	   	return soVector;
	}
	public class TestDataTemplate extends DataTemplate 
	{
		public TestDataTemplate(DataView view, int rows, int columns) 
		{
			super(view, rows, columns);
		}
		public Field[] getDataFields(int modelRowIndex) 
		{
			TableModel theModel = (TableModel) getView().getModel();

			Object[] data = (Object[]) theModel.getRow(modelRowIndex);

			Field[] theDataFields = new Field[data.length];

			for(int i=0; i < data.length; i++) 
			{
				theDataFields[i] = new LabelField((String) data[i],Field.FIELD_HCENTER|DrawStyle.ELLIPSIS|Field.FIELD_VCENTER|Field.USE_ALL_WIDTH);
			}

			return theDataFields;
		}
	}
}

 Here i am able to scroll horizontally and vertically but when i scroll vertically i am unable to see the docked header added....i am able to see only the list of the rows....

 

Also can i know do u add rows to the tableview because i am getting the data from backend and that i loop over and add it to the table view....not sure how u add data.....may be there is a difference there!!

 

Any ideas or suggestions to get rid of this problem is most welcome!!

Highlighted
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Displaying the Header Label and list of records!!

Remove the comments on your call to super that disables vertical scrolling on the VerticalFieldManager of MainScreen.  The entire screen is scrolling instead of the table, which is why your header isn't docked.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker