2017-02-14 4 views
0

私は機能を使用しています。ここで、妥当性検査のエラーが発生した場合、gotoリンクはフォーカス()を持つ必須コンポーネントのIDをページの上部に生成しています。そのリンクをクリックすると、必要なコンポーネントが強調表示されます。今はそのエラーが同じタブにある場合の作業です。しかし、最初のタブはアクティブなフォーカス機能で、3番目のタブの中に必要なテキストボックスをポイントしません。javascript focus()はプライムフェイスのtab1からtab2には作用しません

void encodeGotoLabel(FacesContext context, UIComponent component, ResponseWriter writer, 
      FacesMessage msg) throws IOException { 
      String id = getid(context, msg); 
      if (id != null && !FacesMessage.SEVERITY_INFO.equals(msg.getSeverity()) 
       && !FacesMessage.SEVERITY_FATAL.equals(msg.getSeverity())) { 
       String inputLabel = findInputLabel(context, id); 

       if (inputLabel != null) { 
        ResourceBundle bundle ="bundle"; 

        writer.writeText(" (", null); 
        writer.writeText(bundle.getString("goTo") + " ", null); 
        writer.startElement("a", component); 
        writer.writeAttribute("href", "javascript:document.getElementById('" + id 
         + "').focus();", 
         null); 
        writer.writeText(inputLabel, null); 
        writer.endElement("a"); 
        writer.writeText(")", null); 
       } 
      } 
     } 
+0

多分要素idが同じであるため、最初の要素しか取得できません。 – user1087079

+2

質問が明確ではない、正確に何が必要なの? –

+0

検証エラーのあるタブに切り替えたいですか? –

答えて

0

この機能は、タブのグループにループし、エラーが発生した場合ので、それはそれに切り替えて、必要なフィールドに焦点を当てた場合、チェックし、あなたがする必要があるすべてはあなたの関数でそれを追加します:

var tabs = PF('tabViewWv').getLength(); //tabViewWv is WidgetVar name 
for (var iter = 1; iter <= tabs ; iter++) { 
    if ($('#form\\:tabView\\:tab' + iter).find(':input').hasClass('ui-state-error')) { 
     PF('tabViewWv').select(iter - 1); 
     return false; 
    } 
} 
関連する問題