Form.addComponent() in JSPDynPage
Hi,
I try to generate the HTMLB contents in my iView in 2 way. First to delegate to jsp using the setJspName() method...that works fine. But the second way to add a component by form.addComponent() method. That works not. I want to do this both in the JSPDynPage context.
Further explanation: I wrote some abstract classes and interfaces for iView development. In a properties file I define iView states and to each iView state a gui.
E.g. entry in the properties:
IVIEW_STATE_1=first.jsp
IVIEW_STATE_2=IGSecond
if the iview state ends with .jsp the method setJspName() will be invoked. If it ends not with .jsp, I reflect the class IGSecond which implements my GuiGenerator interface. In this class IGSecond I return a htmlb Component. This happens in the processBeforeOutput() in JSPDynPage. The component is delivered correctly, but not shown.
Now my final question: is it possible to use setJspName() and form.addComponent in a JSPDynPage ?
Thanks a lot
Oliver
...I solved this...the problem was that I inherited from JSPDynPage. It seems, that the form member is null in this case. So I can not use jsps with htmlb and the htmlb classlib. Now I inherit from DynPage and used the decompiled code to delegate to the jsp. Now it works, I can generate the gui with jsps or htmlb classlib or both in my framework.
Similar Messages
-
Execute Interactive form with JSPDynPage component
Hi all,
I need to use interactive forms in my project.
Can i use interactive forms in my JSPDynpage components?
Regards
Gabriel García.Hi,
A Presentation from tech ed
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/26e9dc90-0201-0010-a790-a7048c8bba95
A blog
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/88e7ea34-0501-0010-95b0-ed14cfbeb85a
Adobe Online Interactive Forms Integration into Web Dynpro for Java Applications - Webinar Details
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cf8dc795-0801-0010-ae97-af93a0795b3f
Regards
Ayyapparaj -
Focus remains in Button when showing Form
Hi all,
I have a Form into which there are Container, GridLayout, Label's, TextField's, and Button's.
Here is the code :
package hello;
import com.sun.lwuit.*;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.GridLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import javax.microedition.midlet.MIDlet;
import java.util.Hashtable;
import javax.microedition.rms.*;
public class HelloMIDlet extends MIDlet implements ActionListener {
private Form form;
private Command ajoutCommand,exitCommand;
private Container panel;
private GridLayout layout;
private Label cin,nom,prenom,adresse;
private TextField cinField,nomField,prenomField,adresseField;
private Button btnAjout, btnExit;
private Hashtable tTheme;
private RecordStore base;
private String dataDB;
public HelloMIDlet() {
public void startApp() {
Display.init(this);
try
Resources r = Resources.open("/resources.res");
tTheme = r.getTheme("Theme");
UIManager.getInstance().setThemeProps(tTheme);
catch (java.io.IOException e)
System.err.println("error reading resource file !");
try {
base = RecordStore.openRecordStore("LWUITBase", true);
catch (RecordStoreException ex) {
ex.printStackTrace();
form = new Form("test");
panel = new Container();
layout = new GridLayout(4,2);
panel.setLayout(layout);
ajoutCommand = new Command("Ajouter",1);
exitCommand = new Command("Exit", 2);
//form.addCommand(ajoutCommand);
//form.addCommand(exitCommand);
cin = new Label("CIN :");
cinField = new TextField();
//cinField.setConstraint(TextArea.NUMERIC);
nom = new Label("Nom :");
nomField = new TextField();
prenom = new Label("Prénom :");
prenomField = new TextField();
adresse = new Label("Adresse :");
adresseField = new TextField();
btnAjout = new Button(ajoutCommand);
btnAjout.addActionListener(this);
btnExit = new Button(exitCommand);
btnExit.addActionListener(this);
panel.addComponent(cin);
panel.addComponent(cinField);
panel.addComponent(nom);
panel.addComponent(nomField);
panel.addComponent(prenom);
panel.addComponent(prenomField);
panel.addComponent(adresse);
panel.addComponent(adresseField);
panel.addComponent(btnExit);
panel.addComponent(btnAjout);
cinField.setFocus(true);
form.addComponent(panel);
form.show();
public void pauseApp() {
public void destroyApp(boolean unconditional) {
notifyDestroyed();
public void actionPerformed(ActionEvent evt) {
if (evt.getCommand() == exitCommand)
destroyApp(false);
else
if (evt.getCommand() == ajoutCommand)
insert();
public synchronized void insert()
String record = cinField.getText() + ";" + nomField.getText() + ";" + prenomField.getText() + ";" + adresseField.getText();
byte[] bytes = record.getBytes();
try {
base.addRecord(bytes, 0, bytes.length);
cinField.setText("");
nomField.setText("");
prenomField.setText("");
adresseField.setText("");
catch (RecordStoreException ex) {
ex.printStackTrace();
RecordEnumeration enumRec = null;
try {
enumRec = base.enumerateRecords(null, null, false);
} catch (RecordStoreNotOpenException ex) {
ex.printStackTrace();
while(enumRec.hasNextElement())
try {
dataDB = new String(enumRec.nextRecord());
} catch (RecordStoreException ex) {
ex.printStackTrace();
Dialog.show("Confirm","data = "+dataDB,"Ok","Cancel");
So when running the application then the cursor is on the Exit button but not on the "cinField" field as I coded.
So how to make the cursor in the "cinField" field after showing the Form ?
Another problem : when I set a NUMERIC constraint to the "cinField" field then when I try to enter a value in it then I cannot type numbers , and I must click the T9 command ! So how to make the application ready to accept numbers in that situation ?
Thank you very much indeeduse button.requestFocus();
-
Problem with next month for DateNavigator in DynPage
Hi
I have a problem with using the DateNavigator in DynPage.
I can not navigate to the previous/next month by using the event onNavigate();
The following is my code
public void doProcessBeforeOutput() throws PageException {
IPageContext pagecontext = this.getPageContext();
Form form = this.getForm();
DateNavigator dn = new DateNavigator(pagecontext);
dn.setId("myDateNavigator1");
dn.setMonthsPerColumn(1);
dn.setMonthsPerRow(1);
dn.setCenteredMonth(3);
dn.setOnNavigate("myOnNavigate");
form.addComponent(dn);
public void onMyOnNavigate(Event event){
DateNavigatorNavigationEvent nvEvent = (DateNavigatorNavigationEvent) event;
DateNavigator dn = (DateNavigator)this.getComponentByName(nvEvent.getComponentName());
if ("next".equals(nvEvent.getDirection())){
dn.setCenteredMonth(4);
if ("previous".equals(nvEvent.getDirection())){
dn.setCenteredMonth(2);
Does anybody know what is the problem with it? Or konw how to control the navigation?
Thank you for help.
Best Regards
ZhouHi
I have a problem with using the DateNavigator in DynPage.
I can not navigate to the previous/next month by using the event onNavigate();
The following is my code
public void doProcessBeforeOutput() throws PageException {
IPageContext pagecontext = this.getPageContext();
Form form = this.getForm();
DateNavigator dn = new DateNavigator(pagecontext);
dn.setId("myDateNavigator1");
dn.setMonthsPerColumn(1);
dn.setMonthsPerRow(1);
dn.setCenteredMonth(3);
dn.setOnNavigate("myOnNavigate");
form.addComponent(dn);
public void onMyOnNavigate(Event event){
DateNavigatorNavigationEvent nvEvent = (DateNavigatorNavigationEvent) event;
DateNavigator dn = (DateNavigator)this.getComponentByName(nvEvent.getComponentName());
if ("next".equals(nvEvent.getDirection())){
dn.setCenteredMonth(4);
if ("previous".equals(nvEvent.getDirection())){
dn.setCenteredMonth(2);
Does anybody know what is the problem with it? Or konw how to control the navigation?
Thank you for help.
Best Regards
Zhou -
Connectivity between "SAP Connector and Java Iview".
hi Experts,
I have written a Java iview, and trying to connect r/3 by the java Iview, i am not able to track where i am goin wrong ?? Please help.
Is there anyway to check whether the connectivity is been established or not.I am really confused.
Code is :-
package com.rr.ess.DynPage;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.functions.IInteraction;
import com.sapportals.connector.execution.functions.IInteractionSpec;
import com.sapportals.connector.metadata.functions.IFunction;
import com.sapportals.connector.metadata.functions.IFunctionsMetaData;
import com.sapportals.htmlb.Button;
import com.sapportals.htmlb.Form;
import com.sapportals.htmlb.GridLayout;
import com.sapportals.htmlb.Image;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.TextView;
import com.sapportals.htmlb.Tray;
import com.sapportals.htmlb.enum.InputFieldDesign;
import com.sapportals.htmlb.enum.TrayDesign;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.ivs.cg.ConnectionProperties;
import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
import com.sapportals.portal.ivs.cg.IConnectorService;
import com.sapportals.portal.prt.component.IPortalComponentProfile;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.resource.IResource;
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sun.corba.se.spi.legacy.connection.Connection;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
public class TestDynPage extends PageProcessorComponent {
public DynPage getPage() {
return new TestDynPageDynPage();
public static class TestDynPageDynPage extends DynPage {
Tray mytray;
Image Logo;
InputField myinputfield;
Button mybutton;
Button defaultbutton;
TextView text;
GridLayout mygrid;
String message;
String Str = new String();
* Initialization code executed once per user.
public void doInitialization() {
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
this.message = profile.getProperty("mymessage");
if(this.message=="")
this.message = profile.getProperty("defaultmessage");
* Input handling code. In general called the first time with the second page request from the user.
public void doProcessAfterInput() throws PageException {
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
InputField myinput = (InputField)getComponentByName("input");
if(myinput != null)
message = myinput .getValueAsDataType().toString();
try{
getConnection(request,"P35");
catch(Exception e)
public IConnection getConnection(IPortalComponentRequest request,String alias)
throws Exception {
IConnectorGatewayService cgService =
(IConnectorGatewayService) PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
ConnectionProperties prop = new ConnectionProperties(request.getLocale(),request.getUser());
IConnection connection = cgService.getConnection("P35",request);
getSAPdata(connection);
return cgService.getConnection("P35", prop);
public void getSAPdata(IConnection client) throws Exception {
/* Start Interaction * */
try{
IInteraction ix = client.createInteractionEx();
IInteractionSpec ixspec = ix.getInteractionSpec();
ixspec.setPropertyValue("Name", "HRMSS_RFC_EP_READ_PHOTO_URI");
// Create IFunction instance
IFunctionsMetaData functionsMetaData = client.getFunctionsMetaData();
IFunction function = functionsMetaData.getFunction("HRMSS_RFC_EP_READ_PHOTO_URI");
// CCI api only has one datatype: Record
RecordFactory recordFactory = ix.getRecordFactory();
MappedRecord importParams = recordFactory.createMappedRecord("CONTAINER_OF_IMPORT_PARAMS");
// Set scalar values
importParams.put("PERNR", "1012");
// Get scalar values
System.out.println("Invoking... " + function.getName());
MappedRecord exportParams = (MappedRecord) ix.execute(ixspec, importParams);
String scalar = (String)exportParams.get("URI");
Str = scalar;
finally {
if (client != null) {
try {
client.close();
//("* Iview: Closing connection ok.");
client = null;
} catch (Exception e) {
// logMsg("* Iview: Error closing connection.");
* Create output. Called once per request.
public void onPersonalise(Event event) throws PageException
IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
profile.setProperty("mymessage",this.message);
profile.store();
public void onDefault(Event event) throws PageException
IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
this.message = profile.getProperty("defaultmessage");
profile.setProperty("mymessage","");
profile.store();
public void doProcessBeforeOutput() throws PageException {
// create your GUI here....
IPortalComponentRequest req= (IPortalComponentRequest)getRequest();
//IResource rs = req.getResource(IResource.IMAGE,"images/CAR1.jpg");
IResource rs = req.getResource(IResource.IMAGE,Str);
Logo = new Image(rs.getResourceInformation().getURL(req),"Logo");
Form myForm = this.getForm(); // get the form from DynPage
myinputfield = new InputField("Input");
myinputfield.setDesign(InputFieldDesign.STANDARD);
mybutton = new Button("mybutton");
mybutton.setText("Personlise");
mybutton.setOnClick("Personalise");
defaultbutton = new Button("Default");
defaultbutton.setText("Default");
defaultbutton.setOnClick("Default");
text = new TextView("fgfdg"+Str);
mytray = new Tray();
mytray.setDesign(TrayDesign.BORDER);
//mytray.addComponent(Logo);
form.addComponent(Logo);
mygrid = new GridLayout(3,2);
mygrid.setCellPadding(2);
mygrid.addComponent(1,1,myinputfield);
mygrid.addComponent(2,1,mybutton);
mygrid.addComponent(3,1,defaultbutton);
mygrid.addComponent(3,2,text);
mytray.addComponent(mygrid);
myForm.addComponent(mytray);
Points would be awarded to helpful answers.
Regards,
Sanjyoti.hi Prashant,
Thanks for your reply.
I am able to see the Iview with all the components(textfield,buttons).
But the image is not displayed. and I am not able to check whether the connectivity is been established.
in this part of code
text = new TextView("fgfdg"+Str);
I am assigning the value of "Str", which i get from R/3 to "text",
but in the iview the value of "Str" is not displayed.
Regards,
Sanjyoti -
Proplem: Access HTMLB controls from java code
Hi,
I am new to iView development for EP6. So my problem should be easy to solve (for you ).
I created in the NW Dev Studio a JSP DynPage.
The following files were created or edited:
1. JSP file (created)
2. java file (created)
3. portalapp.xml (edited)
In order to make the page running (proccessing) I changed the following things:
1. JSP file Add taglib reference to HTMLB-class
2. portalapp.xml Remove the native property so the JSP file will not be accessed directly.
Now I want to do the following:
On the JSP page I placed severeal HTMLB controls (textViews).
From the java code I try to access these controls in the doProcessBeforeOutput method and change/set values.
But I get all the time a null-Exception.
Code (JSP)
<%-- mcmsprovider.jsp --%>
<%@ taglib uri= "tagLib" prefix="hbj" %>
<hbj:content id="cntMcmsProvider" >
<hbj:page title="MCMS Provider Dynpage">
<hbj:form id="frmMcmsProvider" >
<hbj:textView id="tvwScript" encode="false"></hbj:textView>
<hbj:textView id="tvwStyle" encode="false"></hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>
Code (JAVA):
public void doProcessBeforeOutput() throws PageException {
this.setJspName("mcmsprovider.jsp");
TextView tvw = (TextView) this.getComponentByName("tvwStyle");
tvw.setText("Here the dynamic text");
I also tried to add raw text to the form but also null excpetion:
public void doProcessBeforeOutput() throws PageException {
this.setJspName("mcmsprovider.jsp");
Form frmCurrent = (Form) this.getForm();
frmCurrent.addRawText("<h3>This comes from here</h3>");
My goal is to dynamically add controls to the form, but until now I think it will be a dream:
public void doProcessBeforeOutput() throws PageException {
this.setJspName("mcmsprovider.jsp");
Form form = (Form)this.getForm();
TextView tvw = new TextView("tvwDynamic");
tvw.setText("Here the dynamic control");
form.addComponent(tvw);
The normal page processing runs:
public void doProcessBeforeOutput() throws PageException {
this.setJspName("mcmsprovider.jsp");
Any help is greatly appreciated.Eike
Here is the example straight from the PDK documentation. This should help you a little
UsingAbstractPortalComponentWithHTMLB.java
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.DataType;
import com.sapportals.htmlb.enum.GroupDesign;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.rendering.IPageContext;
import com.sapportals.htmlb.rendering.PageContextFactory;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class UsingAbstractPortalComponentWithHTMLB extends AbstractPortalComponent {
//Fill in your output for "normal" content creation mode here
protected void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
IPageContext myContext = PageContextFactory.createPageContext(request, response);
if (myContext == null) {
System.out.println("htmlb service did not start up as expected.");
Form myForm = myContext.createFormDocument("First Experiment");
Event lastEvent = myContext.getCurrentEvent();
Group myGroup = new Group();
myGroup.setWidth("350");
myGroup.setTitle("First Experiment");
myGroup.setDesign(GroupDesign.SAPCOLOR);
myForm.addComponent(myGroup);
GridLayout gl = new GridLayout();
myGroup.addComponent(gl);
if ((lastEvent != null) && (lastEvent.getComponentName().equals("submit"))) {
String name = myContext.getDataForComponentId("USER_NAME").toString();
TextView label = new TextView("Hi, " + name);
gl.addComponent(1, 1, label);
Button myButton = new Button("goback", "Go back");
myButton.setOnClick("goBack"); // ignored anyway
gl.addComponent(2, 1, myButton);
} else {
TextView label = new TextView("What's your name?");
gl.addComponent(1, 1, label);
InputField inf = new InputField("USER_NAME");
inf.setType(DataType.STRING);
gl.addComponent(1, 2, inf);
Button myButton = new Button("submit", "Tell");
myButton.setOnClick("submit");
gl.addComponent(2, 2, myButton);
myContext.render(); -
Hi all,
I am using DynPage for my development.
I have 6 iViews in a page.1 iView will be in left side,and the other iViews are in right side(same position).
based on the user click the link from left iView,I have to make visible the other iViews in right side.
See my code..
public void doProcessBeforeOutput() throws PageException {
Form form = (Form)this.getForm();
Link link1 = new Link("outfrontnow");
link1.setTarget("_self");
link1.addText("Link to OutFrontNow RSS");
link1.setOnClientClick("doRelativeNavigate()");
form.addRawText("<SCRIPT language ='JavaScript'>"
+"function doRelativeNavigate(){"
+"EPCM.doRelativeNavigate( \"ROLES://portal_content/RSS_BP/com.wipro.Rssuser/com.wipro.RSS/OutFront\");"
+"}"
+"</SCRIPT>"
form.addComponent(link1);
The other iView is opening in a new page in portal.
But as I said I want to open the other iView in right side of the same page.
How do I achieve this?
Could anyone please help me.
Thankx in advance.
Regards,
SwapnaHI Swapna
You can choose a Page layout, say with two columns. Add all your iViews to this page.
You can then edit the <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/85/09e13dc2fd605ae10000000a11405a/frameset.htm">page layout</a> where you can drag and drop the iViews into the desired containers.
Check out the that link and do revert back.
Best Regards
Priya -
Eventing between Web Dynpro iView and regular DynPage iView
I have seen, done eventing between two dynpage iviews and two webdynpro iviewsHowever, and gone through "How to Use the Portal Eventing for Web Dynpro iViews". However, I have been trying to have a webdynpro iview talk to a dynpage iview but they just won't communicate. Is this even possible?
Ok basically I have a portal page in a popup window with no masthead and top level navigation. The page has two iviews - the top one being an iView that points to a webdynpro application on Server A, and the bottom one being a dynpage iview on the Portal Server B.
In the webdynpro iview, the code for when a button is clicked is
public onSomeAction(Event event) {
WDPortalEventing.fire("urn:myUrn","eventName","value");
In the dynpage iview, the code i have for it is
myServ = (IEpcfToolbox) PortalRuntime.getRuntimeResources().getService(IEpcfToolbox.KEY);
myReceiver = myServ.getClientEventReceiver(request, "urn:myUrn", "eventName");
form.addRawText(myReceiver.getWrappedScript());
try {
if (!myReceiver.isReceived()) {
form.addComponent(createMainScreen());
} else {
form.addComponent(new TextView("event received!"));
} catch (Exception e) {
form.addComponent(createErrorScreen());
I tried all the things I could think of but the receiving iView just won't get the event fired.
Can someone confirm that this should work? and correct me where I've done wrong.
Please help. this is very urgent. your help will be greatly appreciated. thanks in advance
PS. My environments are EP 6.0 SP2 and WAS 6.40 SP14> hi,
>
> portal eventing works properly if all participants
> are in the same domain. Otherwise portal eventing
> g does not work. If the SAP J2EE
> Engine on which the Web Dynpro application is
> deployed is in another domain, you have to map the
> IP address of the SAP J2EE Engine to the domain name
> of the
> SAP J2EE Engine on which the SAP Enterprise Portal is
> running, by editing the configuration file hosts.
>
> regards,
>
> Ganesh.N
I am no direct access to the boxes so I can't try your suggestion. It really makes sense that eventing won't work if the iViews are on different domains. I know they are in the same domain but different subdomains.
Anyway, good news I got eventing to work with the mentioned set. I found that that the SAP Java EPCFToolbox API had a bug that kept throwing javascript errors when I tried to have the web dynpro iview fire an event and the SAP one subcribed to it.
I got around it but using the EPCF Javascript API instead.
Code:
response.write("<script>");
response.write("EPCM.subscribeEvent('urn:dla.telework', 'createPdf', doSomething);");
response.write("function doSomething() {");
response.write("window.location = self.location + '&eventReceived=true';");
response.write("}");
response.write("</script>");
So basically just output raw text through the response object and it just works.
On a similar topic, since eventing can only pass string parameters back and forth, I'm still looking for a way to pass other more complex Java objects between web dynpro and sap iviews. From what I haven't they don't share the same session object (which I thought they did). So basically I can't just stick stuff in the session and pull it down on the other end. I'm clueless right now. If anybody has some tips, plesae share. Thanks -
A Portal Application IView (again)
Hi!
This Portal Application 'create' an HTML document with a Form: this Form may contain 1 or 2 Tables.
IPageContext context = PageContextFactory.createPageContext(request, response);
Form form = context.createFormDocument("xxxxxxxxxxxxx");
FormLayout layout = new FormLayout();
layout.addComponent(....);
form.addComponent(layout);
context.render();
This IView has a Height of 200 px.(set into SAP EP)
Now....i'd like to know it there's a way to get the Height of the Table(s) in the Form that i have just created...because i need this value to resize the IView that now is too big when the Form contains only 1 Table.
Thanks!I think what you are asking, might have something to do with Dynamic Memory Management. Memory allocated during runtime for variables. And Java supports it. Since, a portal application is nothing but a Java application, you should be able to implement successfully what you asked.
But, the technical specifics of how you implement above is something I do not know. -
Customizing TreeView component
Hi,
Is it possible to customize the TreeView htmlb Component
with components like checkbox? ... To clearly state my requirement, I would like to add a checkbox at each node of the tree so that I will handle some logic when the checkbox corresponding to the node is selected.
I mean that every node and element should have a corresponding checkbox and when I check a node or element
I should be able to determine whether the value of checkbox(Checked or unchecked) and based on that I will handle some business logic.
Is this customization possible in HTMLB TreeView?
If so, Can you please guide me with the steps?
If not, what is the alternative?
Thanks and regards
DeepaHi,
Now I have created a gridlayout containing a checkbox and text and has placed it as a treenode component.
The code for the same is as follows.
//DynPage
Create output. Called once per request.
public void doProcessBeforeOutput() throws PageException {
// get the form from DynPage
Form form = (Form) this.getForm();
Tree tree = new Tree("sample", "sample");
tree.setTooltip("Personalize your content");
TreeNode rootNode = new TreeNode("sample","sample");
rootNode.setOpen(true);
rootNode.setText("Root Folder");
rootNode.setComponent(getCustomNodeComponent(rootNode));
rootNode.setTooltip("samplepersonalization");
rootNode.setOnNodeClick("onNodeClick");
tree.setRootNode(rootNode);
TreeNode firstLevel = new TreeNode("folders", "folder",rootNode);
firstLevel.setText("folder");
firstLevel.setComponent(getCustomNodeComponent(firstLevel));
firstLevel.setOnNodeClick("onNodeClick");
form.addComponent(tree);
// create your GUI here....
public GridLayout getCustomNodeComponent(TreeNode node)
GridLayout personalize = new GridLayout();
personalize.setId("personalize");
personalize.setCellSpacing(5);
//personalize.setWidth("50%");
//personalize.setDebugMode(true);
String nodeName = node.getText();
GridLayoutCell cell1 = new GridLayoutCell("cell1");
cell1.setContent("<p style=\"font-family:Arial;font-size:70%\">"nodeName"</p>");
personalize.addCell(1,1,cell1);
GridLayoutCell cell2 = new GridLayoutCell("cell2");
Checkbox checkBox = new Checkbox(nodeName+"check");
checkBox.setChecked(true);
cell2.setContent(checkBox);
personalize.addCell(1,2,cell2);
return personalize;
And the tree is also rendered fine with checkbox at each node.
Now my question is how will I get the value of checkbox component in the TreeNode?
Can anyone help me out in this?
Regards
Deepa
Message was edited by: Deepa Jampunathan -
JavaScript error when using HoverMenu
Hi,
I'm using the HoverMenu with the TreeView in my project. When I call JavaScript methods in my form from the menu I get JavaScript Object Expected errors.
For test I have made a simple DynPage iView (see code below). When I try to call the script reloadTree() from buttons, links, checkbox etc. everything works just fine. Trying to call the same method in the setClientSideScript of a hover menu item I get a JavaScript error: Object expected.
I have tried to add the script method as raw text to the form with no luck. If I use the Document.setHeadRawText the script is inserted in the body and not in the header as described in the documentation.
If I add alert('Some test') directly to the setClientSideScript it works just fine
The code example is from the doProcessBeforeOutput()
Document doc = getDocument();
doc.setHeadRawText("<script>function reloadTree(){alert('Alert inside reloadTree function');}</script>");
myForm.addRawText("<a href="#" onClick="reloadTree()">Test of reloadTree() from a href...</a>");
HoverMenu hover = new HoverMenu("HoverMenu");
hover.setMenuTrigger(com.sapportals.htmlb.enum.HoverMenuTrigger.ONCLICK);
hover.addMenuItem("TEST1", "Test of reloadTree() from hovermenu...").setClientSideScript("reloadTree()");
TextView tv = new TextView("click here to test reloadTree()");
tv.setHoverMenu(hover);
form.addComponent(tv);
Button bt_Refresh = new Button("Button_HiddenRefresh");
bt_Refresh.setText("Test of reloadTree() from button");
bt_Refresh.setOnClientClick("reloadTree()");
form.addComponent(bt_Refresh);
Checkbox cb = new Checkbox("Checkbox");
cb.setText("Test from checkbox");
cb.setDisabled(false);
cb.setChecked(true);
cb.setOnClientClick("reloadTree()");
form.addComponent(cb);
Does anyone know why the HoverMenu item script in setClientSideScript cannot access JavaScript functions in my form ?
Regards
MichaelHi,
I'm using the HoverMenu with the TreeView in my project. When I call JavaScript methods in my form from the menu I get JavaScript Object Expected errors.
For test I have made a simple DynPage iView (see code below). When I try to call the script reloadTree() from buttons, links, checkbox etc. everything works just fine. Trying to call the same method in the setClientSideScript of a hover menu item I get a JavaScript error: Object expected.
I have tried to add the script method as raw text to the form with no luck. If I use the Document.setHeadRawText the script is inserted in the body and not in the header as described in the documentation.
If I add alert('Some test') directly to the setClientSideScript it works just fine
The code example is from the doProcessBeforeOutput()
Document doc = getDocument();
doc.setHeadRawText("<script>function reloadTree(){alert('Alert inside reloadTree function');}</script>");
myForm.addRawText("<a href="#" onClick="reloadTree()">Test of reloadTree() from a href...</a>");
HoverMenu hover = new HoverMenu("HoverMenu");
hover.setMenuTrigger(com.sapportals.htmlb.enum.HoverMenuTrigger.ONCLICK);
hover.addMenuItem("TEST1", "Test of reloadTree() from hovermenu...").setClientSideScript("reloadTree()");
TextView tv = new TextView("click here to test reloadTree()");
tv.setHoverMenu(hover);
form.addComponent(tv);
Button bt_Refresh = new Button("Button_HiddenRefresh");
bt_Refresh.setText("Test of reloadTree() from button");
bt_Refresh.setOnClientClick("reloadTree()");
form.addComponent(bt_Refresh);
Checkbox cb = new Checkbox("Checkbox");
cb.setText("Test from checkbox");
cb.setDisabled(false);
cb.setChecked(true);
cb.setOnClientClick("reloadTree()");
form.addComponent(cb);
Does anyone know why the HoverMenu item script in setClientSideScript cannot access JavaScript functions in my form ?
Regards
Michael -
Split a multiline string from TextEdit into multiple strings
Hi all,
I have a small question. I have a string that comes from a multiline TextEdit used for comments. This string has to be split into multiple strings with max 72 chars. The wrapping is set to "hard".
Can anybody help me on this?
Thanks
FranciscoHi Francisco,
this is the complete code I tested, a bit ugly concerning the println etc... (****, not formatting here?):
package com.btexx;
import java.util.StringTokenizer;
import com.sapportals.htmlb.Button;
import com.sapportals.htmlb.Form;
import com.sapportals.htmlb.TextEdit;
import com.sapportals.htmlb.enum.TextWrapping;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.rendering.IPageContext;
import com.sapportals.htmlb.rendering.PageContextFactory;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class TextEditExample extends AbstractPortalComponent
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
IPageContext pageCtx = PageContextFactory.createPageContext(request, response);
Event lastEvent = pageCtx.getCurrentEvent();
if (lastEvent == null) {
Form form = pageCtx.createFormDocument("myFormDocument");
TextEdit te = new TextEdit("Edit_Text");
te.setId("TextEditID");
te.setText("Text to change - or just add text");
te.setWrapping(TextWrapping.HARD);
te.setTooltip("Edit and/or add text");
te.setRows(10);
te.setCols(72);
form.addComponent(te);
Button btn = new Button("MyButton");
btn.setOnClick("react");
form.addComponent(btn);
pageCtx.render();
} else {
TextEdit te = (TextEdit) pageCtx.getComponentForId("TextEditID");
String text = te.getText();
// for (int j = 0; j < text.length(); j++) {
// System.out.println(text.getBytes()[j] + " - " + text.substring(j, j+1));
StringTokenizer st = new StringTokenizer(text, "nr");
String[] texts = new String[st.countTokens()];
while (st.hasMoreTokens()) {
System.out.println("Line : " + st.nextToken());
I swear, I did not press Return within the TextEdit box, and after that, 13/10 appeared within the text. If just this code does not work the same on your machine, then it seems to be a bug in (your) htmlb (because my P/HF are the most actual, at least they have been yesterday).
Hope it helps
Detlev
Message was edited by: Mark Finnern
added the [code ] [/code ] (without the blanks) -
How to execute a url using a Link
Hai,
I am working on some code and got struck up with the following issue.
There is an input field which allows the user to enter any URL,and by default this filed is populated with a default url,
below this input field there is a link, when the user clicks on this link,
the URl that is entered by the user should get executed, and i am using PageProcessor component for this.
code Sample :
InputField input = new InputField("applicationURL/Path");
form.addComponent(input);
String TestUrl=input.getString().getValueAsString();
Link testApplicationLink = new Link("testApplicationLink");
testApplicationLink.setReference(TestUrl);
form.addComponent(testApplicationLink);
Thanks in advance
regards
jagdeshHi jagdesh,
Are you using Web Dynpro or Portal components? For portal related questions use Enterprise Portal forum section /community [original link is broken]
Best regards, Maksim Rashchynski. -
Access to HTMLB with JavaScript in DynPage class
Hi, in the documentation JavaScript API of SAP HTMLB Guidelines there is an example code in 4 parts.
1.
Form form = (Form)this.getForm();
nputField inf2 = new InputField("currencyDisplay");
inf2.setJsObjectNeeded(true);
inf2.setClientEvent(EventTrigger.ON_CHANGE, "calculateCurrencyToFrom()");
inf2.setBCD("100");
inf2.setWidth("250px");
form.addComponent(inf2);
2.
function calculateCurrencyFromTo() {
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var inputfield = eval(func("currencyDisplay"));
if (inputfield)
inputfield.setValue("100.23"); }
3.
InputField inf2 = new InputField("currencyDisplay");
String inputfieldID = pageContext.getParamIdForComponent(inf2);
4.
<script> var inputfield = eval(inputfieldID);</script>
I try to run this code in DynPage class. I put the code part 1 in doBeforeProcess(), then use form.addRawText() to send JavaScript code to client.
<script> var inputfield = eval(inputfieldID);
function calculateCurrencyFromTo(){
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var inputfield = eval(func("currencyDisplay"));
if (inputfield)
inputfield.setValue("100.23");}
</script>
question:
Where to put the part 3 in order to detect the input field is selected or triger the event? Thank you for help.
Yantong WangHi Raymond,
Try out the following piece of code (the code is tested and is working):
<hbj:textEdit id="addComments"
wrapping="SOFT"
text=""
rows="2"
cols="100" >
<% addComments.setJsObjectNeeded(true); %>
</hbj:textEdit>
Then through javascript you can access the id of the text edit in the similar fashion.
var txtAdCom= eval(func("addComments"));
var value =txtAdCom.getValue();
var length = txtAdCom.getValue().length;
Please do reward with points if the solution is helpful.
Thanks
Ritushree -
Creating the JSPDynPage ( form name="myFormName" method="post" action=""
Hi All,
I am developing JSPDynPage example ,in this example i am using html tags instead of business HTML . So when i am submitting the JSP page , what is the name of the action i have to set in action method.
So please provide me detailed information for the above query and that would be greatly appreciated
Regards
Siva
This is my java class :
public class test extends PageProcessorComponent
below i am posting the my jsp page code:
<jsp:useBean id="myBean" scope="request" class="test.testmyBean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<form name="myFormName" method="post" action="">
<input type="text" name="T1" size="20" value="<%=(myBean == null)?"":myBean.getText()%>">
<input type="submit" value="Submit" name="B1" onClick="javascript:fntCheck();">
</form>
<script language="javascript">
function fntCheck()
document.myFormName.submit();
</script>
</hbj:page>
</hbj:content>Hi Siva,
We can use <hbj:form> tag in our HTML code. So use <hbj:form> tag in place of normal HTML <form> tag and place a <hbj:button> tag in the hidden part of the HTML code.
When the user clicks on the HTML button, at that time call javascript to trigger the <hbj:button> button. This will submit the form to the server as the same way as submitting the page of HTMLB.
We implimented this in our project.
Follwing are the steps to do:
1. Replace <form> tag with<b><hbj:form></b> tag.
2. Add the follwing code in your JSP.
<b><div style="visibility:hidden;">
<hbj:button
id="Update"
encode="false"
text="Update"
width="125px"
tooltip="Click here to update address data."
onClick="Update"
disabled="false"
design="STANDARD"
jsObjectNeeded="TRUE"
/>
</div></b>
3. Add the follwing line of code in <u>'fntCheck()' </u>javascript function.
<b>
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var buttonUpdate = eval(func("Update"));
document.getElementById(buttonUpdate.id).onclick();</b>
Deploy & Run.
Cheers....
Satya
Maybe you are looking for
-
Iphone 5 syncing error, code 1156?
I am getting an error message that says cannot sync, an unknown error occured, (1156). I've already restored the iphone 5 twice. its brand new. anyone have a clue what this code means?
-
Producing a string of 3 random letters for a hash table
I'm pretty new to all this and i was wondering if anyone would be able to help me produce a random string of 3 letters to be inputted into a hash table. I already have the code for integers to be placed into the table but am having difficulty with le
-
Hello all, I'm trying to read a raw image, not a camera raw, but a byte image from a satellite that has no headers, etc. CS3 would read the image just fine by file/open and setting it to read all documents, format= photoshop raw. Doing the same with
-
Selecting a portion of a JComponent
Hi, I need to provide the ability for a user to select a portion of a JComponent. My final aim is to obtain the Rectangle coordinates for the selection, but while selecting, the user should be able to see a box around the selection area as he is drag
-
Safari 3.2 crash - how I fixed mine
Safari 3.2 seems to crash under different conditions for different users. From what I have read, the most common conditions are: a) incompatible third-party add-ons (e.g. PithHelmet, AcidSearch, etc); b) Having the option 'Warn when visiting a fraudu