cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing FAQ

Former Member
0 Kudos

Hello,

We have a requirement to implement 'FAQ's on portal where when the user opens the iview he is given a set of questions as links and when he clicks on it he goes down on the page to view the answer.....like we have faqs on websites....how can we implement this using webdynpro java iviews....?

Any help would be highly appreciated.

Regards,

Anil

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I earlier used a Table to store the answers and set the lead selection by binding the answers node....but the user wants to display the answers in plain text rather than in table....

Armin,

Could you please detail out how to use backend file and component controller to do this...?

Former Member
0 Kudos

I earlier used a Table to store the answers and set the lead selection by binding the answers node....but the user wants to display the answers in plain text rather than in table....

Armin,

Could you please detail out how to use backend file and component controller to do this...?

Former Member
0 Kudos

Hi Anil,

In order to implement the FAQ type Web Dynpro View, the following can be done:

1. The Questions on the top of the view should be created as LinkToAction UI Elements.

2. In action handlers of these LinkToAction, you can code it in such a way that, the UIElement Method of requestFocus() is called for the Answer UI element, which can be aTextEdit or TextView.

Also, I would say that, as there can be many such questions, and the list can vary, you can display them in a Table with transparent grid lines.

Similarly, the Nawers can also be rendered in a Table.

Putting them in Table, can make the code simpler, having only 1 Action Handler, where depending on the selected element in the Questions Table Node, you can set the selction or focus on the correspondig element in the Answers Table.

Seems confusing, but if you read it carefully, you'll understand the solution.

Regards,

Alka.

Former Member
0 Kudos

Hello Alka,

Thanks for your help.....I added linkToAction element and created an action for it and created a TextView for the answer....and added the parameter view of type IWDView to the action ....then in the Action i wrote the code as:

IWDTextView tv =(IWDTextView)view.getElement("TextView");

tv.requestFocus();

but at runtime I got NullPointerException at the first line.....seems like we cannot access view except for the wdDoModifyView() method ....then how can I access the TextView UIElement in the Action to call the RequestFocus() method....

Looking forward to your reply.

Regards,

Anil

Former Member
0 Kudos

A very simplistic solution: Create a context node


FAQEntries (node, c=0:n)
- question (string)
- answer (string)

In your view, reserve a container "QuestionLinksContainer" (layout = "RowLayout") for the question links and place a single TextView below. Bind the TextView's "text" property to the "answer" attribute. It will then display the answer of the lead-selected FAQ entry.

Create the links by code inside wdDoModifyView():


if (firstTime) /* or whenever the links should be recreated */
{
  IWDTransparentContainer linkContainer = (IWDTransparentContainer) view.getElement("QuestionLinksContainer");
  linkContainer.destroyAllChildren();
  for (int i = 0; i < wdContext.nodeFAQEntries().size(); ++i)
  {
    IWDLinkToAction link = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, null);
    link.createLayoutData(IWDRowHeadData.class); /* new row */
    linkContainer.addChild(link);
    link.setOnAction(wdThis.wdGetLinkClickedAction());
    link.mappingOfOnAction().addParameter("index", i);
  }
}

Create an action "LinkClicked" with a parameter "index" of type integer. Implement the action handler as


void onLinkClicked(..., int index)
{
  wdContext.nodeFAQEntries().setLeadSelection(index);
}

Armin

Former Member
0 Kudos

Thanks for the reply....but in your code where will the text for the questions and answers be added to display them in the view....as you are adding them at runtime ...

Looking forward to your reply..

Regards,

Anil

Former Member
0 Kudos

I forgot one line.


if (firstTime) /* or whenever the links should be recreated */
{
  IWDTransparentContainer linkContainer = (IWDTransparentContainer) view.getElement("QuestionLinksContainer");
  linkContainer.destroyAllChildren();
  for (int i = 0; i < wdContext.nodeFAQEntries().size(); ++i)
  {
    IWDLinkToAction link = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, null);
    link.createLayoutData(IWDRowHeadData.class); /* new row */
    linkContainer.addChild(link);
    link.setText(wdContext.nodeFAQEntries().getFAQEntriesElementAt(i).getQuestion()); /* ADD THIS LINE */
    link.setOnAction(wdThis.wdGetLinkClickedAction());
    link.mappingOfOnAction().addParameter("index", i);
  }
}

The answer text will appear automatically when the lead selection is set.

Armin

Former Member
0 Kudos

Armin,

Still to get the questions in the for loop we need to set them first somewhere ...i think we are missing something here....

Thanks,

Anil

Former Member
0 Kudos

Create the "FAQEntries" node in the component controller, define a supply-function to fill the node. In the supply function, access the backend/text file (wherever you store the FAQs) and populate the node.

Map the "FAQEntries" node in the view controller to the one in the component controller.

Armin

former_member185086
Active Contributor
0 Kudos

Hi

Apart form the given solution i ll suggest one other way to implement this functionality.

Case 1 : When Set of Question and Answers are predefined .

See this [Tutorials|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/47ce9b90-0201-0010-59b5-f70826824eee] where a file is read at run time which contains some text in your case it will be Q and A , now only thing you have to do is place one view at right hand side which will contain the selected Q and and its corresponding A(will change accoring to selection of the tree which is placed as left naviation)

Case 2. When these object (Q &A )need to define at admin workbench which we available to the client at runtime :

In this case that file will be replaced by the BO(createQuestion and Answers ) given to define the set of object.

(I have implemented this feature by Case 2 by basic idea i have taken form Case 1.)

Hope it help you

Best Regards

Satish Kumar

Former Member
0 Kudos

Thanks all for your help...I finally used ArrayList to populate various Questions and Answers and binded it to the FAQEntries Node....

Anil