cancel
Showing results for 
Search instead for 
Did you mean: 

Save user specific data

0 Kudos

Hi experts,

i have the following question.

I would like to save some information about each user who has used web dynpro application on j2ee engine. In this file (xml, txt ... ) is saved information per user, for example 10 last inputs for filter he used.So that each time on start of an application some list will be suggested with inputs he made.

i have thought that it could be an xml-file with following structure:

<main_data>

<user id="name1>

<info_input>Input1<info_input>

<info_input>Input2<info_input>

........

</user>

<user id="name2">

..........

</user>

</main_data>

Then it could be maybe possible to parse it and to get info for specific user, to save it in context node and bind it to dropdownbyindex ui element.

Have you any ideas? Is it possible? If yes, could you please and explain how?

Thank you very much in advance!

Best Regards,

Daria

Edited by: Daria Sosunova on Jun 3, 2008 5:16 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Daria,

Kranthi is right, for this purpose you'll need some kind of Data Persistency.

Of course you can use XML file for this purpose and write a code like below


  public void wdDoInit() 
  {
    //@@begin wdDoInit()
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder db;
	try {
		db = dbf.newDocumentBuilder();	
		Document doc = db.newDocument();		
		doc.appendChild(doc.createElement("userName"));
		
		String result = convertDOMToString(doc);
		FileOutputStream fos = new FileOutputStream("test.xml", false);
		fos.write(result.getBytes());
		fos.close();
	} catch (ParserConfigurationException e) {			
		logger.catching(e);
	} catch (FileNotFoundException e) {
		logger.catching(e);
	} catch (TransformerException e) {
		logger.catching(e);
	} catch (IOException e) {
		logger.catching(e);
	}
	
    //@@end
  }

...

  private static String convertDOMToString(Document doc) throws TransformerException {
	  //
	  //Now prepare to transform into clean XML
	  //
	  TransformerFactory factory = TransformerFactoryImpl.newInstance();
	  Transformer tf = factory.newTransformer();
	  //
	  //Make sure we get an XML in UTF-8 with no indent or
	  //chinese fonts will get translated into &#....
	  //
	  tf.setOutputProperty(OutputKeys.METHOD, "xml");
	  tf.setOutputProperty(OutputKeys.ENCODING, "utf-8");
	  tf.setOutputProperty(OutputKeys.INDENT, "no");
	  //
	  //Make sure we deal properly with unicode to UTF-8 conversion
	  //
	  StringWriter sw = new StringWriter();
	  Source source = new DOMSource(doc);
	  tf.transform(source, new StreamResult(sw));
	  return sw.toString();
  }

The main disadvantage of this solution is that it won't work in cluster environment.

The best solution will be to use database persistency together with EJB.

Follow this link:

<ul>

<li> [Java Data Objects (JDO)|http://help.sap.com/saphelp_nw04/helpdata/de/91/7917fab0279f418e33762cbbfa6470/frameset.htm] - describes how to create and use JDO objects together with session beans </li>

</ul>

Good luck

Ivan Dulko

Former Member
0 Kudos

You would need some kind of Data Persistency to save your data beyond the user session. You may to develop RFC to store the data in ECC table or Database interface to store directly into Database.

If you use Dropdown list(or EVS with Inputfield), users can't make any selection that is not in your list(well, there is a way with some tweaking).

If you really want to make appealing solution, develop a Portal component using JSP Dynpage with AJAX. Web Dynpro doesn't allow application developer to use AJAX.

Cheers,

~kranthi