0
votes

I feel like my brain is going to explode. Please help.

I have a select element with options loaded from the category list standard component. It has a value of Group:{!groupCategory} referring to it's public string on my custom controller.

I have an apex:inputText component with a value of {!searchString} referring to it's public string on my custom controller.

I have an apex:commandButton component that rerenders a panel group that writes my articles from the knowledge:articlelist component.

My issue is the {!groupCategory} is not receiving the selected option value from my select element(assumption), but when I use javascript to log the select elements value it returns the value of the option that is selected.

What's weird is the {!searchString} value is set and read by the knowledge:articlelist component.

NOTE: I removed the currentPagenumber calculation from the controller to keep things simple and I can't see how it would be relevant to the issue at hand. Also, I am using standard HTML select element opposed to the apex selectlist component because knowledge:categorylist cannot be nested within selectList.

KeywordSearchController:

public with sharing class KeywordSearchController {

 //Page Size
 private Static Final Integer PAGE_NUMBER = 5;

 //Search String used in ArticleList tag
 public String groupCategory { get; set; }
 public String searchstring  { get; set; }


 public KeywordSearchController() {
  String qryString = 'SELECT Id, title, UrlName, 
  LastPublishedDate,LastModifiedById FROM KnowledgeArticleVersion WHERE 
  (PublishStatus = \'online\' and Language = \'en_US\')';
  List<KnowledgeArticleVersion> articleList= Database.query(qryString);
  maxSize = articleList.size() ;
  }

Visualforce Page:

<apex:page showHeader="false" standardStyleSheets="false" controller="KeywordSearchController">

<apex:form>

 <select id="groupSelect" value="{!groupCategory}">
  <knowledge:categoryList categoryVar="category" categoryGroup="Group" rootCategory="All" level="-1">
   <option value="Group:{!category.name}">{!category.label}</option>
  </knowledge:categoryList>
 </select>

 <div class="field is-grouped">
  <p class="control is-expanded has-icons-left">
   <apex:inputText styleClass="input is-medium" value="{!searchstring}"  />
    <span class="icon is-left">
     <i class="fa fa-search"></i>
    </span>
  </p>

 <p class="control">
  <apex:commandButton value="Search" id="submitButton" styleClass="button is-primary is-medium"  reRender="theSearchResults"/>
 </p>
 </div>
</apex:form>

<apex:form >
 <apex:messages />
 <apex:pageBlock title=""> 
 <apex:panelGroup id="theSearchResults" >
 <apex:panelGrid width="100%">
 <table class="table is-striped is-narrow">
 <thead>
 <tr>
  <th>Title</th>
  <th>Article Type</th>
  <th>Summary</th>
 </tr>
 </thead>
<knowledge:articleList articleVar="article" categories="{!groupCategory}" 
 pageNumber="{!currentPageNumber}" Keyword="{!searchstring}" 
 hasMoreVar="false" pageSize="5">
 <tbody>
 <tr>
  <td>
   <apex:outputLink target="" value="{!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'false'])}">{!article.title}</apex:outputLink>
  </td>
  <td><apex:outputText >{!article.articleTypeLabel}</apex:outputText></td>
  <td><apex:outputText >{!article.abstract}</apex:outputText></td>
 </tr>
 </tbody>
 </knowledge:articleList>
 </table>
 </apex:panelGrid> 
</apex:panelGroup>
</apex:pageBlock>
</apex:form>
1
It's definitely something with using the standard select element. Using the selectList to set the value of the {!groupcategory} string works just fine (manually typing in each option). Which isn't practical for staying dynamic. - S.B.

1 Answers

0
votes

You should be using the tag instead of the standard html tag. There is no built-in set binding for standard html tags, only ones.